Not finding wanted result in query string

Hello

We have an Elasticsearch 5.5 setup. We use nest to perform our queries through C#.

When executing the following query:

{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "00917751"
          }
        }
      ]
    }
  }
}

We get the desired result: one result with that the number as identifier.

When executing the query:

{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "917751"
          }
        }
      ]
    }
  }
}

We get no results.

The value we are searching for is in the field searchIndentifier, and has the value "1-00917751".

We have a custom analyzer called "final"

.Custom("final", cu => cu
.Tokenizer("keyword").Filters(new List() { "lowercase" }))

The field searchIndentifier has no custom analyzer set on it. I tried adding the whitespace tokenizer in it but that made no difference.

Another field called "searchObjectNo" does work, when I try to search for the value "S328-25" with the query "S328". These fields are exactly the same.

Any ideas here?

Another question:
When executing the query

{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "1-00917751"
          }
        }
      ]
    }
  }
}

we get a lot of results. I would like this to return only 1 result. How would we accomplish this?

Thank you
Schoof

Settings and mapping: https://jsonblob.com/9dbf33f6-cd3e-11e8-8f17-c9de91b6f9d1

You might want to take a look at the analyze API to understand tokenization a bit better. I would also recommend using the match query instead of the query_string one if possible, as it takes field mappings into account.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.