Queries seem to ignore custom analyzer

I'm using a custom analyzer to stem possessive english. My custom analyzer
seems to be ignored. As a sample search, we'll use "McDonald's".

What I used to create my analyzer:

{
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"stop",
"pos_english"
]
}
},
"filter": {
"pos_english": {
"type": "stemmer",
"name": "possessive_english"
}
}
}
}
}

My mapping:

{
"item": {
"_boost": {
"name": "custom_boost",
"null_value": 1
},
"properties": {
"servings": {
"enabled": false,
"type": "object"
},
"brand_name": {
"index": "analyzed",
"type": "string",
"store": false
},
"food_name": {
"index": "analyzed",
"type": "string",
"store": false
}
}
}
}

When I test the analyzer for the text 'McDonald's', it seems to work
properly:

{
"tokens": [
{
"token": "mcdonald",
"start_offset": 0,
"end_offset": 10,
"type": "",
"position": 1
}
]
}

However, if I search for 'McDonald', I get no results. If I search for
'McDonald's' (with the possessive), I get my expected results. It seems
like the analyzer is being ignored during the query.

Search query that returns no results:

{
"query": {
"match": {
"_all": {
"query": "mcdonalds"
}
}
}
}

Any idea what I'm doing wrong?

--
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/93e3e3b3-1fc7-443d-970e-47bb43c757e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You did not apply this analyzer to _all field.

The default one is applied.

My 2 cents

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 25 mai 2014 à 01:15, Alex Philipp alex@snapfiber.com a écrit :

I'm using a custom analyzer to stem possessive english. My custom analyzer seems to be ignored. As a sample search, we'll use "McDonald's".

What I used to create my analyzer:

{
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"stop",
"pos_english"
]
}
},
"filter": {
"pos_english": {
"type": "stemmer",
"name": "possessive_english"
}
}
}
}
}

My mapping:

{
"item": {
"_boost": {
"name": "custom_boost",
"null_value": 1
},
"properties": {
"servings": {
"enabled": false,
"type": "object"
},
"brand_name": {
"index": "analyzed",
"type": "string",
"store": false
},
"food_name": {
"index": "analyzed",
"type": "string",
"store": false
}
}
}
}

When I test the analyzer for the text 'McDonald's', it seems to work properly:

{
"tokens": [
{
"token": "mcdonald",
"start_offset": 0,
"end_offset": 10,
"type": "",
"position": 1
}
]
}

However, if I search for 'McDonald', I get no results. If I search for 'McDonald's' (with the possessive), I get my expected results. It seems like the analyzer is being ignored during the query.

Search query that returns no results:

{
"query": {
"match": {
"_all": {
"query": "mcdonalds"
}
}
}
}

Any idea what I'm doing wrong?

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/93e3e3b3-1fc7-443d-970e-47bb43c757e4%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/6F5ECFF8-F10E-4223-B79A-947CC8255123%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.