c-toesca
c-toesca

Reputation: 1017

ElasticSearch returns no result on bool filter containing dash

I have indexed 2 objects (ES 1.5)

{
    tags: ["tag1","bla-bla"]
}

{
    tags: ["tag2"]
}

If I make this request:

{
    "query": {
        "filtered": {
            "filter": {
                "bool": {
                    "should":
                    [
                        {
                            "term": {
                                "tags": "bla-bla"
                            }
                        }
                    ]
                }
            }
        }
    }
}

Elastic return no result because there is "-" in "tags" field.

If I search this, it works, I have 1 result:

...
    "term": {
         "tags": "tag1"
    }
...

Can someone explain why when I put a dash ("-") in the "tags" field, there is no result ?

Upvotes: 0

Views: 88

Answers (1)

alpert
alpert

Reputation: 4655

If not specified a custom one Elasticsearch will use Standart Analyzer to analyze fields. And standart analyzer will remove punctions (- in your case) and tokenize your terms as [tag1, bla].

You can check analyzed forms with term vectors:

GET <index>/<type>/<id>/_termvectors?fields=tags

Upvotes: 2

Related Questions