Okay i figured out query for my situation but the result coming back has
few records that i wasnt expecting
data in index:
"1", "John", "Doe", "johndoe@somecompany.com"
"2", "Johny", "Doey", "johndoe34@somecompany.com"
"3", "Johnathan", "Chang", "johndoe56@ somecompany.com"
"4", "longjohn", "silver", "johndoe76@somecompany com"
"5", "dijohn", "Doera", "johndoe12@ somecompany.com"
"6", "papajohn", "Do", "johndoe09@somecompany.com"
"7", "ojohnyyy", "Dey", "johndoe87@somecompany.com"
"8", "jerry", "seinfield", "someemails@somecompany.com"
"9", "kramer", "dicosta", "someemailagain@somecompany.com"
*Following query is returning all the records: *
curl -XGET 'http://localhost:9200/index/_search?&pretty=true' --data-binary
'{"query":{"query_string":{"fields":["firstName","lastName"],"query":"john
doe","use_dis_max":true}}}'
Records with id's from 1-7 are correct and are expected but 8 & 9 are also
being returned which dont really match any of the values passed in query.
Any ideas on how to ignore/remove the last 2 records from search result?
On Thursday, October 11, 2012 12:39:18 AM UTC-7, hemantp wrote:
I am new to Elasticsearch and am currently migrating the lucene queries
that i have. Following is the setup for index properties :
index :
analysis :
analyzer :
myStandard :
tokenizer : nGram
filter : [standard, lowercase, stop]
"user" : {
"_source" : { "enabled" : true },
"properties" : {
"userId" : { "type" : "string", "index" : "analyzed",
"analyzer" : "myStandard" },
"firstName" : { "type" : "string", "index" : "analyzed",
"analyzer" : "myStandard" },
"lastName" : { "type" : "string", "index" : "analyzed",
"analyzer" : "myStandard" },
"email" : { "type" : "string", "index" : "not_analyzed"}
}
}
Situation is that user can enter any text in search box to search for user
and search needs to be performed against firstName and lastName. It would
be a OR query with both prefix and suffix wild card. Like firstName OR
lastName
exact matches of firstName and lastName have to be displayed top. What
would be best way to acheive this? bool query?? also is nGram the correct
tokenizer in these situations?
--