I’m changing a full text search in my MVC application (using MySql) to Lucene .NET.
My personalized search has some quirks that i’m having trouble reproducing in Lucene.
The big one is something like this:
Customer 1 has Customer 2 in his contact list, and has assigned him a keyword, lets say “Mom”. This is a private keyword, only Customer 1 can see it, and it only works when Customer 1 searches.
Customer 1 Searches “Mom”:
- Customer 2
- Product 3
- Etc..
Customer 2 Searches “Mom”:
- Product 3
- Etc..
Basically, it’s a Tag with a user identifier.
How do i do this in Lucene?
The only way I can think of is to have a private index for each user with the keywords in the documents and search using my standard index and the user private index.
The problem is that I will end up with thousandths of indexes… i don’t know if that is really efficient.
Is there a way to set something in the field of the document so i can save the user id and search in there only when the id matches?
thanks
EDIT:
The requirement is that the keyword “MOM” is added to the document “Customer 2” but i can only use that keyword when Customer 1 searches.
If Customer 2 searches for himself, it will use all other fields but the keyword one.
One way is to add a field to each document that contains both the customer ID and their private keyword, so you end up indexing something like Customer1:mom. Each time a user searches on a private keyword, their customer ID and private keyword are included in the query (like Customer2:mom above).
The bugaboo is that you may need to pre-parse the queries to transform the private keywords. If the private keywords are entered separately in the UI, you won’t need to do that.
Depending on your setup, this method might require adding a lot more fields to your index, but at least it could still be 1 index, not thousands.