in Fscrawler is it possible to derive index name from subfolder name? - fscrawler

I have a folder with several hundred sub folders and would like to index by these sub folder names...That is after running fscrawler I would like to have several hundred different indices...The default is one index (e.g."job_name") for all the sub directories...Is it possible to create indexes for each individual sub folder?

Two options I can think of:
One job per folder
Using an ingest pipeline where you can overwrite the index name with a set processor.

Related

Cascade deletion of database record to deletion of associated image file

I recently discovered the wonders of foreign keys and deletion cascading with InnoDB and I love it. It helps me easily delete intricate data structures without worrying about leaving junk behind.
I'm currently storing images for a products database (like you would have on a web-shop) in the following manner:
My products table is what you would expect, it has an id primary column.
My product_images table has a product_id column with a foreign key to the products.id column, and an image column of type varchar storing the image file name.
The file names are created by computing the SHA1 hash of the image, then storing in a folder named after the first 2 characters of the hash:
61/6153A6FA0E4880D9B8D0BE4720F78E895265D0A9.jpg. In the database, only 6153A6FA0E4880D9B8D0BE4720F78E895265D0A9.jpg is stored.
Now, if I were to delete a product from the database, the cascading DELETE rule would delete the record in the product_images table, but would leave the file on my server.
Is there a way to automate the deletion of the image file whenever a record in the product_images table is deleted, be it specifically or by cascading? Maybe link some kind of trigger or routine to the deletion operation?
There is no native functionality built into mysql to perform this. If there were, there would be no end in sight to turning it into feature-creep and a full blown high-level programming language. Bloat-ware, getting away from its core competency.
People have used UDF libraries compiled in C that integrate into mysql either as object files or compiled into the server source. See the sections Adding New Functions to MySQL, and UDF Repository for MySQL. It become like a science fair project, where after you get it to work once, you probably won't want to roll it out to a fleet of other servers.
So what are you alternatives? The safe bets are always to write to another table (outside of your cascade delete hierarchy) the directory/filename combo. And have another mini-system do the housecleaning for you. For instance, twice a day, in Java or c# or python (any language). Those environments have db libraries, and robust file operations. It will be tremendously easier that way anyway.
I do these type of things to extend the functionality of mysql-related activities that are primarily file based or forbidden calls inside of stored procedures and events.
You would use below code for deleting the specific file.
Note: your file name ($filName) would come from your query.
$filName;
$dirName = substr($filName, 0, 2);
chown($filName,465);
unlink("../".dirName."/" . $filName);
when inserting images to DB change it's name to be linked with it's product
or it's category .
when deleting category search for imaged that have names involve cat id then unlink it
this code can help
foreach(glob(IMG_PATH.'cat_'.$_POST['id'].'*.*') as $file)
{
if(is_file($file))
{
#unlink($file);
}
}

Neo4J custom load CSV

I asked a question a few days ago to know how to import an existing database into Neo4J. Thanks to the person who explained me how to do that. I decided to create a CSV file from my database (around 1 million entries) and to load it from the Neo4j webadmin to test it. The problem is that each row of this database contains redundant data, for example my database contains actions from different users but each user can do mutliple actions. The structure of my graph would be to create a node for each user that is linked to each action he does. That's why I have to create only one node for each user even if his name appears in several rows of my CSV file (because he made several actions). What is the method to do that ? I guess it's possible to do that in Cypher right ?
Thanks a lot
Regards
Sam
In case you have references that might or might not exist, you should use the MERGE statement. MERGE either finds something or creates something in your database.
Please refer to the respective section in the reference manual: http://docs.neo4j.org/chunked/stable/cypherdoc-importing-csv-files-with-cypher.html. Here the country is shared my multiple users there the country is merged wheres the users and their relationships to countries are unconditionally created.

How do I to add multiple directories to an SQL database while sharing the same schema?

A buddy of mine needed help adding multiple directories to an SQL database while sharing the same schema yet have different listings. I've scoured my "MySQL" books and Google, I can't find any definitive information. I was just hoping someone here knew how to do this.
To clarify, there are a total of 12 directories. 11 are to be searched independently of one another and the 12th (which already exists) will be a directory comprised of all 11 directories, all of which will have the same schema.
The goals are to create these unique directories using the existing schema model, and to upload multiple directory entries at a time to the directories.
Does this mean the names of the directory entries have to be unique (ie. Name_1, Name_2, Name_3, etc...?) Or, will it be a matter of duplicating the schema under a different name? Any advise will help.
A directory, in this context, is like a roledex. I mean to have 12 roledexes with each rolodex having unique entries frem eachother. How do you approach this database-wise?
After logging into your PHPMyadmin select or go in to the table you want to duplicate-and-rename, then click on "Operations." There you see a series of boxes with one called "Copy table to (database.table)" You can choose to duplicate structure and data, or structure only. Type the name you want and click go. And your new table with listing will be ready to edit and search!
If I understand what you're asking... I think you want to create a new database for each "directory," as you put it, with the same table definitions in it.
The word "database" in mySQL parlance means the same thing as "schema" in the parlance of some other RDBMS systems. You can't have two sets of data with the same table names in the same database (a/k/a schema). You need a different schema for this.
It's very common to have lots of databases in a single server with precisely the same tables / columns / keys etc. And yes, phpmyadmin can handle this.
The word "directory" is confusing, though. It ordinarily refers to the on-disk data storage used by the mySQL (RDBMS) server program. But I don't think that's what you mean. If you DO mean it, please make sure you are highly skilled at system administration before you try to muck around with the file systems on the mySQL server. It's easy to break stuff. (Ask me how I know how easy it is to break stuff :-) :-)

Mysql Folders and Documents

I want to have folders and documents which every one have a folder. Folders can have infinite children folders. What is the best mysql schema in your opinion.Do you think this is good?
Table Folders
id
name
parent (if null the root)
auth_user (access control type)
created_date
created_by
Table documents
id
name
type
idFolder (FK id of folders)
auth_user (access control type)
created_date
created_by
Do you think the above is good or gonna have problem later? Do you think with the above can get fast and easy the folders tree (i think with ORDER BY parent ASC can get the tree right)?
adjacency lists are nice for inserts and moving sub-trees but if you need to query deeper than one level it's pain in the a** because you will end up with n-joins if you go n-levels deep. An example: Show me all descendants/ancestors of Folder X.
I suggest to use the adjacency list (the parent_id) in combination with one of the following models:
Nested Sets
Materialized Paths
I really like the nested set - but it has a draw back - inserts are slow. But usually you will have more reads (browsing) the structure than inserting new nodes.
Another thing:
I usually put folders and documents in the same table and flag them with a boolean is_folder column. I like to think of folders/files as "nodes" in a tree so they're basically the same. Further metadata will be stored in another table.

Create Directory for records in MS Access 2007

Is it possible to create a directory folder for individual records in Access 2007. For example
tblUser
ID
firstName
surName
When adding a record, would create a folder C:\userdatabase\Surname,firstName,ID
Could see this being useful in situations for example where a large amount of images/files would need to be associated with a record. Access would create and link to a directory for each record.
Thanks in advance for any advice
Noel
You can use the VBA MkDir statement to make a directory.
For example if you want to create a folder whose name matches one of your ID values, as a sub folder under the directory where your database is stored, you could use this code:
MkDir CurrentProject.Path & "\" & ID
To create the entire directory structure with one command:
link text
While these are all interesting answers to the question asked, I have to wonder why the original poster thinks this is necessary. If you're using your database to keep track of the information, it shouldn't really matter where the files are stored.
Of course, if you need to have access to the files from the file system, this can be a way to do it, but in my experience, usually not the most useful way (it segregates the data to too high a degree).
So, I'm basically saying to go back and question whether the design is correct or not. It very well may be, but you should be certain before committing to something like this, which I consider to be unnecessarily convoluted.