How to use completion-suggester for city-location suggests respecting zip-codes


(Thorsten-3) #1

Dear ElasticSearchers,
I'm trying to get the new completion suggester to help me suggesting my
users locations (cities).

My data mapping and data looks like this.https://gist.github.com/ThorstenS/7039670

What I want is that the names of the cities can be misspelled, and the user
still gets some (hopefully correct) results.
On the other hand, if the user searches via zip-code, the fuzziness should
not be applied to the zip-code, but only to the name of the city.

In my example data above, if i'd search for
curl -X POST 'localhost:9200/geodb/_suggest?pretty' -d '{
"city-suggest" : {
"text" : "12345 Ci",
"completion" : {
"field" : "suggest",
"fuzzy" : {
"edit_distance" : 2
}
}
}
}'

I'd get 2 results, but since I entered a valid zip-code, I'd only like to
get the one result with that exact zip-code. But still maintain fuzziness
on the name of the city.

I do understand that ElasticSearch's behavior totally makes sense, since
I've requested the data with a fuzzy span.
But is there a way to reach my goal?

Thanks for your help :slight_smile:

--
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.


(simonw-2) #2

try using the "prefix_length" parameter and set it to the length of you
zipcode then the fuzziness will not be applied to that prefix

simon

On Friday, October 18, 2013 12:44:18 PM UTC+2, Thorsten wrote:

Dear ElasticSearchers,
I'm trying to get the new completion suggester to help me suggesting my
users locations (cities).

My data mapping and data looks like this.https://gist.github.com/ThorstenS/7039670

What I want is that the names of the cities can be misspelled, and the
user still gets some (hopefully correct) results.
On the other hand, if the user searches via zip-code, the fuzziness should
not be applied to the zip-code, but only to the name of the city.

In my example data above, if i'd search for
curl -X POST 'localhost:9200/geodb/_suggest?pretty' -d '{
"city-suggest" : {
"text" : "12345 Ci",
"completion" : {
"field" : "suggest",
"fuzzy" : {
"edit_distance" : 2
}
}
}
}'

I'd get 2 results, but since I entered a valid zip-code, I'd only like to
get the one result with that exact zip-code. But still maintain fuzziness
on the name of the city.

I do understand that ElasticSearch's behavior totally makes sense, since
I've requested the data with a fuzzy span.
But is there a way to reach my goal?

Thanks for your help :slight_smile:

--
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.


(Thorsten-3) #3

Thank you, that does the trick!

Any chance to increase the number of returned results?
At the moment, I only get a maximum of 5 suggestions, although there are
more locations in the index that should match the query.

Thanks

Thorsten

Am Freitag, 18. Oktober 2013 21:09:37 UTC+2 schrieb simonw:

try using the "prefix_length" parameter and set it to the length of you
zipcode then the fuzziness will not be applied to that prefix

simon

On Friday, October 18, 2013 12:44:18 PM UTC+2, Thorsten wrote:

Dear ElasticSearchers,
I'm trying to get the new completion suggester to help me suggesting my
users locations (cities).

My data mapping and data looks like this.https://gist.github.com/ThorstenS/7039670

What I want is that the names of the cities can be misspelled, and the
user still gets some (hopefully correct) results.
On the other hand, if the user searches via zip-code, the fuzziness
should not be applied to the zip-code, but only to the name of the city.

In my example data above, if i'd search for
curl -X POST 'localhost:9200/geodb/_suggest?pretty' -d '{
"city-suggest" : {
"text" : "12345 Ci",
"completion" : {
"field" : "suggest",
"fuzzy" : {
"edit_distance" : 2
}
}
}
}'

I'd get 2 results, but since I entered a valid zip-code, I'd only like to
get the one result with that exact zip-code. But still maintain fuzziness
on the name of the city.

I do understand that ElasticSearch's behavior totally makes sense, since
I've requested the data with a fuzzy span.
But is there a way to reach my goal?

Thanks for your help :slight_smile:

--
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.


(simonw-2) #4

"size" : X should work just fine no?

simon

On Saturday, October 19, 2013 11:11:58 AM UTC+2, Thorsten wrote:

Thank you, that does the trick!

Any chance to increase the number of returned results?
At the moment, I only get a maximum of 5 suggestions, although there are
more locations in the index that should match the query.

Thanks

Thorsten

Am Freitag, 18. Oktober 2013 21:09:37 UTC+2 schrieb simonw:

try using the "prefix_length" parameter and set it to the length of you
zipcode then the fuzziness will not be applied to that prefix

simon

On Friday, October 18, 2013 12:44:18 PM UTC+2, Thorsten wrote:

Dear ElasticSearchers,
I'm trying to get the new completion suggester to help me suggesting my
users locations (cities).

My data mapping and data looks like this.https://gist.github.com/ThorstenS/7039670

What I want is that the names of the cities can be misspelled, and the
user still gets some (hopefully correct) results.
On the other hand, if the user searches via zip-code, the fuzziness
should not be applied to the zip-code, but only to the name of the city.

In my example data above, if i'd search for
curl -X POST 'localhost:9200/geodb/_suggest?pretty' -d '{
"city-suggest" : {
"text" : "12345 Ci",
"completion" : {
"field" : "suggest",
"fuzzy" : {
"edit_distance" : 2
}
}
}
}'

I'd get 2 results, but since I entered a valid zip-code, I'd only like
to get the one result with that exact zip-code. But still maintain
fuzziness on the name of the city.

I do understand that ElasticSearch's behavior totally makes sense, since
I've requested the data with a fuzzy span.
But is there a way to reach my goal?

Thanks for your help :slight_smile:

--
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.


(Thorsten-3) #5

Thank you for being patient with me, I did give that a try before, but got
an exception.
Just had the parameter placed on the wrong spot...

All working fine now :slight_smile:

curl -X POST 'localhost:9200/geodb/_suggest?pretty' -d '{
"city-suggest" : {
"text" : "12345 City",
"completion" : {
"field" : "suggest",
"size" : 20,
"fuzzy" : {
"edit_distance" : 2,
"prefix_length" : 5
}
}
}
}'

Am Samstag, 19. Oktober 2013 20:17:57 UTC+2 schrieb simonw:

"size" : X should work just fine no?

simon

On Saturday, October 19, 2013 11:11:58 AM UTC+2, Thorsten wrote:

Thank you, that does the trick!

Any chance to increase the number of returned results?
At the moment, I only get a maximum of 5 suggestions, although there are
more locations in the index that should match the query.

Thanks

Thorsten

Am Freitag, 18. Oktober 2013 21:09:37 UTC+2 schrieb simonw:

try using the "prefix_length" parameter and set it to the length of you
zipcode then the fuzziness will not be applied to that prefix

simon

On Friday, October 18, 2013 12:44:18 PM UTC+2, Thorsten wrote:

Dear ElasticSearchers,
I'm trying to get the new completion suggester to help me suggesting my
users locations (cities).

My data mapping and data looks like this.https://gist.github.com/ThorstenS/7039670

What I want is that the names of the cities can be misspelled, and the
user still gets some (hopefully correct) results.
On the other hand, if the user searches via zip-code, the fuzziness
should not be applied to the zip-code, but only to the name of the city.

In my example data above, if i'd search for
curl -X POST 'localhost:9200/geodb/_suggest?pretty' -d '{
"city-suggest" : {
"text" : "12345 Ci",
"completion" : {
"field" : "suggest",
"fuzzy" : {
"edit_distance" : 2
}
}
}
}'

I'd get 2 results, but since I entered a valid zip-code, I'd only like
to get the one result with that exact zip-code. But still maintain
fuzziness on the name of the city.

I do understand that ElasticSearch's behavior totally makes sense,
since I've requested the data with a fuzzy span.
But is there a way to reach my goal?

Thanks for your help :slight_smile:

--
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.


(simonw-2) #6

good stuff!! We are also working on adding support for a geo location in
the suggester that allows you to "pre-filter" based on where the users "is"
or it's "view" / "BoundingBox" center is.

happy that is worked out

simon

On Saturday, October 19, 2013 9:01:38 PM UTC+2, Thorsten wrote:

Thank you for being patient with me, I did give that a try before, but got
an exception.
Just had the parameter placed on the wrong spot...

All working fine now :slight_smile:

curl -X POST 'localhost:9200/geodb/_suggest?pretty' -d '{
"city-suggest" : {
"text" : "12345 City",
"completion" : {
"field" : "suggest",
"size" : 20,
"fuzzy" : {
"edit_distance" : 2,
"prefix_length" : 5
}
}
}
}'

Am Samstag, 19. Oktober 2013 20:17:57 UTC+2 schrieb simonw:

"size" : X should work just fine no?

simon

On Saturday, October 19, 2013 11:11:58 AM UTC+2, Thorsten wrote:

Thank you, that does the trick!

Any chance to increase the number of returned results?
At the moment, I only get a maximum of 5 suggestions, although there are
more locations in the index that should match the query.

Thanks

Thorsten

Am Freitag, 18. Oktober 2013 21:09:37 UTC+2 schrieb simonw:

try using the "prefix_length" parameter and set it to the length of you
zipcode then the fuzziness will not be applied to that prefix

simon

On Friday, October 18, 2013 12:44:18 PM UTC+2, Thorsten wrote:

Dear ElasticSearchers,
I'm trying to get the new completion suggester to help me suggesting
my users locations (cities).

My data mapping and data looks like this.https://gist.github.com/ThorstenS/7039670

What I want is that the names of the cities can be misspelled, and the
user still gets some (hopefully correct) results.
On the other hand, if the user searches via zip-code, the fuzziness
should not be applied to the zip-code, but only to the name of the city.

In my example data above, if i'd search for
curl -X POST 'localhost:9200/geodb/_suggest?pretty' -d '{
"city-suggest" : {
"text" : "12345 Ci",
"completion" : {
"field" : "suggest",
"fuzzy" : {
"edit_distance" : 2
}
}
}
}'

I'd get 2 results, but since I entered a valid zip-code, I'd only like
to get the one result with that exact zip-code. But still maintain
fuzziness on the name of the city.

I do understand that ElasticSearch's behavior totally makes sense,
since I've requested the data with a fuzzy span.
But is there a way to reach my goal?

Thanks for your help :slight_smile:

--
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.


(system) #7