Reputation: 1666
Suppose I have to store student academic details like...
College name
-- text field searchable Student Class
-- text field searchable Subjects
-- multivalue field , text field searchableHow do I store/handle "Student class" because student can search like this "students of class 4th
" , "Students of class 4
" , "student of class fourth
"
How Can I handle these (4th, 4, fourth) variations? What are elegant ways to do so.
Thanks Amit Aggarwal
Upvotes: 0
Views: 159
Reputation: 3474
One way to solve this problem is to use a field type that supports query time synonyms. Check out the "text_general" type in the example solr schema.
In practice you would add rows like this to the synonyms.txt file in your cores conf dir:
# numbers
1,1st,first
2,2nd,second
3,3rd,third
4,4th,fourth
Now, lets suppose you had a document such as:
{ "college":"Princeton", "class":"1", "subjects":["CS 101", "introduction to full text search"]}
You could then retrieve that document if you do a query such as:
class:first
In this example the search query is directed towards one field, which may or may not be what you want. If you need to target the search query with number synonym matching into multiple fields( ie, search query with no field specifier, just the search term), you could copy all those fields content into a single synonym searchable field (using copyField) such as content_synonyms and then run the query against this field by default.
Upvotes: 1