Preserving Position while searching

I need to make elasticsearch query to work with multiple words. I am using edgeNgram tokenizer to support autocompletion feature and I am using query_string for searching.

DOCUMENTS

{
"title":"Gold digital cinema",
"region":"MUMBAI"
}
{
"title":"cine park",
"region":"MUMBAI"
}
{
"title":"Premier Gold",
"region":"MUMBAI"
}

QUERY
{
"query": {
"bool": {
"should": [
{
"query_string": {
"fields": [
"title.default_title^10",
"title.ngrams_front^2"
],
"query": "gold cine",
"boost": 2
}
},
{
"fuzzy": {
"title.default_title": {
"value": "gold cine",
"min_similarity": 0.5,
"max_expansions": 50,
"prefix_length": 0
}
}
},
{
"query_string": {
"fields": [
"region"
],
"query": "MUMBAI"
}
}
]
}
}
}
When I search for gold cine, I need "title":"Gold digital cinema" to be in the top results. But I am getting "title":"cine park" and "title":"Premier Gold" in top.

Is there any way to preserve position while searching? Thanks in advance.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/bddde391-125d-40ea-8e4b-0b34fbf087d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You have options:

  1. Use a match phrase query instead of a query string query.
  2. Use the keyword tokenizer with an edge ngram token fitler on index and
    just use the keyword tokenizer on query.
  3. Add the match phrase query as another should clause and give it a boost
    of 10 or something.

Each of these will produce different results so play with them.

I should also point out that exposing query_string to users without
escaping can give them the power to dump tons of load on Elasticsearch.
The match query type is typically a better choice. Typically.

Nik

On Sat, May 24, 2014 at 10:04 AM, Radhiks H.S. radhika.s@bookmyshow.comwrote:

I need to make elasticsearch query to work with multiple words. I am using
edgeNgram tokenizer to support autocompletion feature and I am using
query_string for searching.

DOCUMENTS

{
"title":"Gold digital cinema",
"region":"MUMBAI"
}
{
"title":"cine park",
"region":"MUMBAI"
}
{
"title":"Premier Gold",
"region":"MUMBAI"
}

QUERY
{
"query": {
"bool": {
"should": [
{
"query_string": {
"fields": [
"title.default_title^10",
"title.ngrams_front^2"
],
"query": "gold cine",
"boost": 2
}
},
{
"fuzzy": {
"title.default_title": {
"value": "gold cine",
"min_similarity": 0.5,
"max_expansions": 50,
"prefix_length": 0
}
}
},
{
"query_string": {
"fields": [
"region"
],
"query": "MUMBAI"
}
}
]
}
}
}
When I search for gold cine, I need "title":"Gold digital cinema" to be in
the top results. But I am getting "title":"cine park" and "title":"Premier
Gold" in top.

Is there any way to preserve position while searching? Thanks in advance.

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/bddde391-125d-40ea-8e4b-0b34fbf087d4%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAPmjWd0n913XSsXgPXJd8j0ckN2rfUmgCWtBH_XhBpFuActW6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Thank you Nikolas for your valuable information..I'll try it out..

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f8b4ab83-f1ed-4564-980e-ae37cf94f7c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.