Hi guys, I'm hoping somebody on here can help me, I feel like I'm just
missing something really basic but I can't for the life of me figure out
what... I have the following index set up (it's very cut down for clarity's
sake):
{
"index":"products",
"body":{
"settings":{
"number_of_shards":5,
"number_of_replicas":1,
"analysis":{
"analyzer":{
"default":{
"type":"snowball",
"language":"English"
},
"reverse":{
"type":"custom",
"language":"English",
"tokenizer":"standard",
"filter":["standard","lowercase","stop","snowball","reverse"]
}
}
}
},
"mappings":{
"product":{
"properties":{
"_all":{"enabled":true},
"id":{"type":"string","include_in_all":true,"index":"analyzed","analyzer":"snowball","store":"yes"},
"name":{"type":"string","include_in_all":true,"index":"analyzed","analyzer":"snowball","store":"yes"},
"name_reverse":{"type":"string","include_in_all":true,"index":"analyzed","analyzer":"reverse","store":"yes"}
}
}
}
}
}
I'm then running search queries against this and I'm now trying to do
suggesters. The following query works fine and returns no "suggests" as
expected:
{
"index":"products",
"type":"product",
"body":{
"indices_boost":{"id":2,"name":1.5},
"query":{
"filtered":{
"query":{
"query_string":{
"query":"pushchair",
"fields":["id","name"]
}
}
}
},
"suggest":{
"text":"pushchair",
"simple_phrase":{
"phrase":{
"field":"name",
"size":4,
"real_word_error_likelihood":0.95,
"confidence":1,
"gram_size":1,
"direct_generator":[
{
"field":"name",
"suggest_mode":"always",
"min_word_len":1
}
}
}
}
}
}
The next query also works fine and returns the expected suggestions:
{
"index":"products",
"type":"product",
"body":{
"indices_boost":{"id":2,"name":1.5},
"query":{
"filtered":{
"query":{
"query_string":{
"query":"pushchiar",
"fields":["id","name"]
}
}
}
},
"suggest":{
"text":"pushchair",
"simple_phrase":{
"phrase":{
"field":"name",
"size":4,
"real_word_error_likelihood":0.95,
"confidence":1,
"gram_size":1,
"direct_generator":[
{
"field":"name",
"suggest_mode":"always",
"min_word_len":1
}
}
}
}
}
}
As you can see, "pushchair" is spelt incorrectly and then response from
Elasticsearch provides the correct suggestion. The problem comes when I try
to add in reverse support as follows:
{
"index":"products",
"type":"product",
"body":{
"indices_boost":{"id":2,"name":1.5},
"query":{
"filtered":{
"query":{
"query_string":{
"query":"pushchair",
"fields":["id","name"]
}
}
}
},
"suggest":{
"text":"pushchair",
"simple_phrase":{
"phrase":{
"field":"name",
"size":4,
"real_word_error_likelihood":0.95,
"confidence":1,
"gram_size":1,
"direct_generator":[
{
"field":"name",
"suggest_mode":"always",
"min_word_len":1
},{
"field":"name_reverse",
"suggest_mode":"always",
"min_word_len":1,
"pre_filter":"reverse",
"post_filter":"reverse"
}
]
}
}
}
}
}
Now I start hitting problems. A query for "pushchair" returns results and
no suggestions (as expected), a query for "pushchiar" returns no results
and a suggestion to use "pushchair" instead. The problem is when querying
"upshchair", I get 0 results and 0 suggestions... My understanding of
providing a reversed index and reverse filters on the suggester was that it
would then reverse match on "riahchspu" and "riahchsup" and return
"pushchair" as a suggestion.
I can also see that the reverse analyzer's working because when I hit
localhost:9200/searchable/_analyze?analyzer=reverse&text=pushchair I get
the following response:
{"tokens":[{"token":"riahchsup","start_offset":0,"end_offset":9,"type":"","position":1}]}
Any help would be much appreciated.
--
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/31d30976-402d-47e7-8dd6-8ec2fc1ef5a6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.