Synonyms and prefix query

hi

how i can combine a prefix query and a synonyme filter ?

this is my query :

{
"query": {
"query_string": {
"query": "samsung",
"analyzer": "synonym",
"fields": [
"name_fr.name_fr",
"name_fr.whitespace",
"name_fr.edge_ngram_front",
"name_fr.edge_ngram_back",
"name_fr.shingle",
"name_fr.shingle_strip_ws",
"name_fr.shingle_strip_apos_and_ws",
"name_fr.analyzer_fr",
"manufacturer",
"description_fr.description_fr",
"description_fr.synonym",
"description_fr.whitespace",
"description_fr.edge_ngram_front",
"description_fr.edge_ngram_back",
"description_fr.shingle",
"description_fr.shingle_strip_ws",
"description_fr.shingle_strip_apos_and_ws",
"description_fr.analyzer_fr",
]
}
},
"min_score": 0.2,
"size": 8,
"filter": {
"synonym": {
"type": "synonym"
},
"and": [
{
"prefix": {
"name_fr.shingle_strip_ws": "samsung"
}
},
{
"query": {
"query_string": {
"query": "exists:type_products_fr"
}
}
}
]
}
}

but I have an exception

nested: QueryParsingException[[magento] No filter registered for [synonym]];

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.

Hey,

The exception you are getting, is actually telling the truth a bit, however
it is pretty hard to extract useful information out of it.

You are trying to use the synonym feature on query time, but this is not
possible. The synonym feature is a tokenfilter and has to be configured,
before you start indexing your documents. It is not to be used on query
time at all.

Consider this example:

curl -X DELETE 'localhost:9200/mytest'
curl -XPUT 'localhost:9200/mytest' -d '{
"settings" : {
"analysis" : {
"analyzer" : {
"my_analyzer" : {
"tokenizer" : "standard",
"filter" : [ "lowercase", "your_synonym_filter" ]
}
},
"filter" : {
"your_synonym_filter" : {
"type" : "synonym",
"synonyms" : [
"foo, bar"
]
}
}
}
}
}'

curl -X PUT localhost:9200/mytest/sometype/_mapping -d ' { "sometype" : {
"properties" : { "name" : { "type" : "string", "analyzer":"my_analyzer"} }
} }'

curl -X PUT localhost:9200/mytest/sometype/1 -d '{ "name" : "what a
wonderful bar" }'

curl -X POST localhost:9200/mytest/sometype/_search -d '{ "query" : {
"match" : { "name" : "bar" } } }'
curl -X POST localhost:9200/mytest/sometype/_search -d '{ "query" : {
"match" : { "name" : "foo" } } }'

When configuring the synonym filter in your index configuration, you can
search either for foo or bar and the indexed document will be returned in
both queries.

Hope this helps...

On Thu, Mar 28, 2013 at 1:16 PM, Fadel Chafai fadelmohamed@gmail.comwrote:

hi

how i can combine a prefix query and a synonyme filter ?

this is my query :

{
"query": {
"query_string": {
"query": "samsung",
"analyzer": "synonym",
"fields": [
"name_fr.name_fr",
"name_fr.whitespace",
"name_fr.edge_ngram_front",
"name_fr.edge_ngram_back",
"name_fr.shingle",
"name_fr.shingle_strip_ws",
"name_fr.shingle_strip_apos_and_ws",
"name_fr.analyzer_fr",
"manufacturer",
"description_fr.description_fr",
"description_fr.synonym",
"description_fr.whitespace",
"description_fr.edge_ngram_front",
"description_fr.edge_ngram_back",
"description_fr.shingle",
"description_fr.shingle_strip_ws",
"description_fr.shingle_strip_apos_and_ws",
"description_fr.analyzer_fr",
]
}
},
"min_score": 0.2,
"size": 8,
"filter": {
"synonym": {
"type": "synonym"
},
"and": [
{
"prefix": {
"name_fr.shingle_strip_ws": "samsung"
}
},
{
"query": {
"query_string": {
"query": "exists:type_products_fr"
}
}
}
]
}
}

but I have an exception

nested: QueryParsingException[[magento] No filter registered for
[synonym]];

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.

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

hi alexander,

yes i configured synonyms before indexing this is my settings :

  • index.analysis.analyzer.synonym.tokenizer: whitespace
  • index.analysis.analyzer.edge_ngram_back.tokenizer: standard
  • index.analysis.filter.shingle.output_unigrams: true
  • index.analysis.analyzer.shingle_strip_apos_and_ws.filter.3: length
  • index.analysis.analyzer.shingle_strip_apos_and_ws.filter.2:
    strip_whitespaces
  • index.analysis.filter.snowball_fr.type: snowball
  • index.analysis.analyzer.shingle_strip_apos_and_ws.filter.4: lowercase
  • index.analysis.filter.shingle.type: shingle
  • index.analysis.filter.strip_whitespaces.type: pattern_replace
  • index.analysis.analyzer.shingle_strip_apos_and_ws.filter.1:
    strip_apostrophes
  • index.analysis.analyzer.shingle_strip_apos_and_ws.filter.0: shingle
  • index.analysis.filter.edge_ngram_front.min_gram: 2
  • index.analysis.filter.edge_ngram_back.side: back
  • index.analysis.filter.length.min: 2
  • index.analysis.filter.strip_apostrophes.replacement:
  • index.analysis.filter.strip_whitespaces.pattern: \s
  • index.analysis.filter.edge_ngram_front.max_gram: 10
  • index.analysis.analyzer.shingle_strip_ws.tokenizer: standard
  • index.analysis.analyzer.edge_ngram_front.tokenizer: standard
  • index.analysis.analyzer.edge_ngram_back.filter.1: edge_ngram_back
  • index.analysis.analyzer.edge_ngram_back.filter.2: lowercase
  • index.analysis.analyzer.edge_ngram_back.filter.0: length
  • index.number_of_shards: 1
  • index.analysis.filter.length.type: length
  • index.analysis.filter.strip_apostrophes.pattern: '
  • index.analysis.analyzer.synonym.filter.0: synonym
  • index.analysis.analyzer.shingle.filter.2: lowercase
  • index.analysis.analyzer.shingle.filter.0: shingle
  • index.analysis.filter.shingle.max_shingle_size: 20
  • index.analysis.analyzer.shingle.filter.1: length
  • index.analysis.filter.edge_ngram_back.max_gram: 10
  • index.analysis.analyzer.edge_ngram_front.filter.0: length
  • index.analysis.filter.synonym.synonyms_path: analysis/synonym.txt
  • index.analysis.analyzer.edge_ngram_front.filter.1: edge_ngram_front
  • index.analysis.analyzer.analyzer_fr.tokenizer: standard
  • index.analysis.analyzer.edge_ngram_front.filter.2: lowercase
  • index.version.created: 191099
  • index.analysis.analyzer.whitespace.tokenizer: standard
  • index.analysis.analyzer.shingle.tokenizer: standard
  • index.analysis.filter.snowball_fr.language: French
  • index.analysis.analyzer.whitespace.filter.0: lowercase
  • index.number_of_replicas: 1
  • index.analysis.analyzer.analyzer_fr.type: custom
  • index.analysis.filter.edge_ngram_front.type: edgeNGram
  • index.analysis.analyzer.shingle_strip_apos_and_ws.tokenizer: standard
  • index.analysis.filter.synonym.type: synonym
  • index.analysis.filter.strip_apostrophes.type: pattern_replace
  • index.analysis.filter.edge_ngram_back.type: edgeNGram
  • index.analysis.analyzer.shingle_strip_ws.filter.3: lowercase
  • index.analysis.analyzer.shingle_strip_ws.filter.2: length
  • index.analysis.analyzer.shingle_strip_ws.filter.1: strip_whitespaces
  • index.analysis.analyzer.analyzer_fr.filter.0: length
  • index.analysis.analyzer.shingle_strip_ws.filter.0: shingle
  • index.analysis.filter.strip_whitespaces.replacement:
  • index.analysis.analyzer.analyzer_fr.filter.1: lowercase
  • index.analysis.filter.edge_ngram_front.side: front
  • index.analysis.analyzer.analyzer_fr.filter.2: snowball_fr
  • index.analysis.filter.edge_ngram_back.min_gram: 2

thank you

On Thursday, March 28, 2013 12:16:30 PM UTC, Fadel Chafai wrote:

hi

how i can combine a prefix query and a synonyme filter ?

this is my query :

{
"query": {
"query_string": {
"query": "samsung",
"analyzer": "synonym",
"fields": [
"name_fr.name_fr",
"name_fr.whitespace",
"name_fr.edge_ngram_front",
"name_fr.edge_ngram_back",
"name_fr.shingle",
"name_fr.shingle_strip_ws",
"name_fr.shingle_strip_apos_and_ws",
"name_fr.analyzer_fr",
"manufacturer",
"description_fr.description_fr",
"description_fr.synonym",
"description_fr.whitespace",
"description_fr.edge_ngram_front",
"description_fr.edge_ngram_back",
"description_fr.shingle",
"description_fr.shingle_strip_ws",
"description_fr.shingle_strip_apos_and_ws",
"description_fr.analyzer_fr",
]
}
},
"min_score": 0.2,
"size": 8,
"filter": {
"synonym": {
"type": "synonym"
},
"and": [
{
"prefix": {
"name_fr.shingle_strip_ws": "samsung"
}
},
{
"query": {
"query_string": {
"query": "exists:type_products_fr"
}
}
}
]
}
}

but I have an exception

nested: QueryParsingException[[magento] No filter registered for
[synonym]];

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.

this query works fine :slight_smile:

{
"query": {
"query_string": {
"query": "nabili",
"analyzer": "synonym",
"fields": [
"name_fr.name_fr",
"name_fr.whitespace",
"name_fr.edge_ngram_front",
"name_fr.edge_ngram_back",
"name_fr.shingle",
"name_fr.shingle_strip_ws",
"name_fr.shingle_strip_apos_and_ws",
"name_fr.analyzer_fr",
"manufacturer",
"description_fr.description_fr",
"description_fr.synonym",
"description_fr.whitespace",
"description_fr.edge_ngram_front",
"description_fr.edge_ngram_back",
"description_fr.shingle",
"description_fr.shingle_strip_ws",
"description_fr.shingle_strip_apos_and_ws",
"description_fr.analyzer_fr",
"isbn_fr",
"manufacturer_facet",
"article_code_manufacturer",
"ean",
"book_author"
]
}
},
"min_score": 0.2,
"size": 8,
"filter": {
"and": [
{
"query": {
"query_string": {
"query": "exists:type_products_fr"
}
}
}
]
}
}

so the problem is with the prefix filter :frowning:

On Thursday, March 28, 2013 12:16:30 PM UTC, Fadel Chafai wrote:

hi

how i can combine a prefix query and a synonyme filter ?

this is my query :

{
"query": {
"query_string": {
"query": "samsung",
"analyzer": "synonym",
"fields": [
"name_fr.name_fr",
"name_fr.whitespace",
"name_fr.edge_ngram_front",
"name_fr.edge_ngram_back",
"name_fr.shingle",
"name_fr.shingle_strip_ws",
"name_fr.shingle_strip_apos_and_ws",
"name_fr.analyzer_fr",
"manufacturer",
"description_fr.description_fr",
"description_fr.synonym",
"description_fr.whitespace",
"description_fr.edge_ngram_front",
"description_fr.edge_ngram_back",
"description_fr.shingle",
"description_fr.shingle_strip_ws",
"description_fr.shingle_strip_apos_and_ws",
"description_fr.analyzer_fr",
]
}
},
"min_score": 0.2,
"size": 8,
"filter": {
"synonym": {
"type": "synonym"
},
"and": [
{
"prefix": {
"name_fr.shingle_strip_ws": "samsung"
}
},
{
"query": {
"query_string": {
"query": "exists:type_products_fr"
}
}
}
]
}
}

but I have an exception

nested: QueryParsingException[[magento] No filter registered for
[synonym]];

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.