Case insensitive nested query string


(Nipun Edara) #1

Hi,

I haven't defined any analyzers and assume it's using the standard analyzer

ES version : 5.6 Lucene_version : 6.6.1

Normal query string results in case-insensitive search but if the query string is put inside nested query it results in case sensitive search

Steps to Reproduce

Create new index test3

PUT test3
{
  "mappings": {
    "articles_batch":{
      "dynamic": "strict",
      "properties": {
        "articleName":{
          "type": "keyword"
        },
        "comments":{
          "type": "nested",
          "properties": {
            "commentName":{
              "type": "keyword"
            }
          }
        }
      }
    }
  },
  "settings": {
    "index":{
      "mapping":{
        "ignore_malformed": "true"
      },
      "number_of_shards":"5",
      "number_of_replicas":"1"
    }
  }
}

Create a document

POST test3/articles_batch
{
  "articleName": "Name1",
  "comments" : [ {
    "commentName":"Hello1"
    },{
    "commentName":"hello2"
    }]
}

Searching for hello1 results in hits

GET test3/articles_batch/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "*hello1*",
            "default_operator": "AND",
            "lenient": true
          }
        }
      ]
    }
  }
}

However, nested search for hello1 doesn't provide any hits

GET test3/articles_batch/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "comments",
            "inner_hits": {
            },
            "query": {
              "query_string": {
                "query": "*hello1*",
                "default_operator": "AND",
                "lenient": true,
                "fields": ["comments.*"]
              }
            }
          }
        }
      ]
    }
  }
}

Any help is greatly appreciated.

Thanks


(David Pilato) #2

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.


(Nipun Edara) #3

Modified the above to include steps to reproduce. Please help.
Thanks


(David Pilato) #4

This query:

GET test3/articles_batch/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "*hello1*",
            "default_operator": "AND",
            "lenient": true
          }
        }
      ]
    }
  }
}

Does not return any hit.

But this one (I modified the text you are searching) does:

GET test3/articles_batch/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "comments",
            "inner_hits": {
            },
            "query": {
              "query_string": {
                "query": "*hello*",
                "default_operator": "AND",
                "lenient": true,
                "fields": ["comments.*"]
              }
            }
          }
        }
      ]
    }
  }
}

One of the problem is that wildcards are not analyzed. And that Hello1 has been indexed as [hello, 1]. So hello1 does not match.


(system) closed #5

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