Hello - I am fairly new to ES and need some help with a ES query.
This is how I built my index:
curl -XPOST 'http://127.0.0.1:9200/test/country?pretty=1' -d '{
"country": ["United States"]}'
curl -XPOST 'http://127.0.0.1:9200/test/province?pretty=1' -d '{
"country": ["United States"],"province" : "NY"}'
curl -XPOST 'http://127.0.0.1:9200/test/city?pretty=1' -d '{ "country":
["United States"],"province" : "NY", "city" : "Albany"}'
curl -XPOST 'http://127.0.0.1:9200/test/district?pretty=1' -d '{
"country": ["United States"],"province" : "NY","city" : "Albany","district"
: "West Albany"}'
curl -XPOST 'http://127.0.0.1:9200/test/district?pretty=1' -d '{
"country": ["United States"],"province" : "NY","city" : "Albany","district"
: "Albany Center"}'
curl -XPOST 'http://127.0.0.1:9200/test/district?pretty=1' -d '{
"country": ["United States"],"province" : "NY","city" : "Albany","district"
: "Shopping District"}'
curl -XPOST 'http://127.0.0.1:9200/test/district?pretty=1' -d '{
"country": ["United States"],"province" : "NY","city" : "Albany","district"
: "Empirical Mile"}'
(It is a simple index with 4 document types: country, province,city, and
district).
From a user, I get a string of text that are that search terms that looks
like the following: "Albany NY".
Every query I have attempted to write never returns my desired top response
which would be a match to the "city" document type (the user never
entered "West Albany"), but this is the top matched returned from the query
below:
curl -XGET 'http://127.0.0.1:9200/test/_search?pretty=1' -d '
{
"query" : {
"bool" : {
"should" : {
"query_string" : {
"query" : "Albany NY"
}
}
}
}
}'
Here are the result of the query:
1){"country": ["United States"],"province" :"NY","city" : "Albany","district" : "West Albany"}
2){"country": ["United States"],"province" :"NY","city" : "Albany","district" :"Albany Center"}
3){"country": ["United States"],"province" :"NY", "city" : "Albany"}
So is there a way to filter out documents that contain terms (eg: "West" or "Center") that were not in passed in the query string
and return {"country": ["United States"],"province" :"NY", "city" : "Albany"} as the first result?
(I hope this question is clear...I posted it on another board, but I was not clear enough :-(, so I am trying again)
Thank you.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.