Hello, I would like to perform an exact match on a string - say for
e.g. the field status which is an enum - taking 2 values
["Automated","To be Automated"].
When I query for status:"To be automated" I require that it return
only those results where status is exactly "To be Automated" and not
"Automated" and if I query for status:"Automated" I again require that
it does not return to me the results where status is "To be
Automated".
I read a previous question where it was suggested that I set index to
not_analyzed or keyword for the above field, but is there a way for me
to get these results without doing the above..and just with the help
of a query? Thanks!
You can but I'm not sure it will be as performat to do it.
You can try a field query where its like
+automated -to -be
and see if that works. The problem is that you are using the default mapping i assume and its going to tokenize those strings.
Thanks,
Shaun Farrell
On Thursday, July 5, 2012 at 1:49 PM, coys wrote:
Hello, I would like to perform an exact match on a string - say for
e.g. the field status which is an enum - taking 2 values
["Automated","To be Automated"].
When I query for status:"To be automated" I require that it return
only those results where status is exactly "To be Automated" and not
"Automated" and if I query for status:"Automated" I again require that
it does not return to me the results where status is "To be
Automated".
I read a previous question where it was suggested that I set index to
not_analyzed or keyword for the above field, but is there a way for me
to get these results without doing the above..and just with the help
of a query? Thanks!
You can but I'm not sure it will be as performat to do it.
You can try a field query where its like
+automated -to -be
and see if that works. The problem is that you are using the default mapping i assume and its going to tokenize those strings.
Thanks,
Shaun Farrell
On Thursday, July 5, 2012 at 1:49 PM, coys wrote:
Hello, I would like to perform an exact match on a string - say for
e.g. the field status which is an enum - taking 2 values
["Automated","To be Automated"].
When I query for status:"To be automated" I require that it return
only those results where status is exactly "To be Automated" and not
"Automated" and if I query for status:"Automated" I again require that
it does not return to me the results where status is "To be
Automated".
I read a previous question where it was suggested that I set index to
not_analyzed or keyword for the above field, but is there a way for me
to get these results without doing the above..and just with the help
of a query? Thanks!
Yep David, you're right, looks I can't find those common words, so I
guess I'll just go ahead and index that field as not_analyzed. Thanks
a lot for the replies guys!
{
"typeofindex" : {
"properties" : {
"metadata.status" : {"type" : "string", "index" : "not_analyzed"}
}
}
}
Just to update, I created this mapping and this worked for me. After
creating this mapping I can now differentiate between fields whose
status are Automated and To be Automated.
Are you getting documents when you search "auto" ? Because the problem with
not_analyzed is it do not search documents with matching type if few of the
words is provided in search query.
On Friday, 6 July 2012 00:11:25 UTC+2, coys wrote:
{
"typeofindex" : {
"properties" : {
"metadata.status" : {"type" : "string", "index" : "not_analyzed"}
}
}
}
Just to update, I created this mapping and this worked for me. After
creating this mapping I can now differentiate between fields whose
status are Automated and To be Automated.
I'll add in what I quickly tested..I have 2 docs..1 which has status
"To be Automated" and 2 which has status "Automated"..search results
are as follows - in my textbox if I type "To" or "To be" or "To be
Automated" it returns 1 correctly..however if I type "Auto" or
"Automated" it only returns doc 2 and does not return doc1..however, I
only provide a comboxbox so I'm able to return the required doc
according to status correctly. Thanks
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.