Search returning no results after upgrade from 7.9.3 to 7.15.0

Hi,

Our Elasticsearch installation was recently updated from 7.9.3 to 7.15.0. (The host operating system was updated from Ubuntu LTS 18 to 20 at the same time.) Following this update, the search scripts and programs were corrected to address deprecation warnings. Documents can be inserted and retrieved successfully, but the wildcard search functionality no longer works with 7.15.0. Looking at the search scripts:

  • One script uses a wildcard following the instructions at Wildcard query | Elasticsearch Guide [7.15] | Elastic , but no longer returns results. Changing the script to use regexp has no effect and no results are returned.
  • Scripts and programs that use the following combinations {"query" and "range"}, {"query", "bool", "must" and"match"} still work.

Is some server configuration needed to cause the wildcard search to start working again? The configuration file /etc/elasticsearch/elasticsearch.yml was updated to explicitly include search.allow_expensive_queries: true but this has no effect.

Thanks,

Will

Hi William,

It's possible that it wasn't working (correctly) in 7.9 and works correctly now in 7.15.
By that I mean you may have been relying on a "false positive" bug in matching.

I recently catalogued the matching behaviour of all queries on all field types with all case-sensitivity options across multiple versions and stored the match correctness results in this gist.

This test result from 7.9.0 is an example of a false positive bug:

{"version": "7.9.0", "queryType": "wildcard", "fieldType": "text", "query": "{\"wildcard\": {\"s.text\": {\"value\": \"*ALLUPPER*\"}}}", "result": "FP"}

An uppercase wildcard query term on a lower-cased text field should never have matched.
This was rectified in a later version to return nothing,
If you want the case insensitive matching behaviour back the wildcard and regexp queries now have case_insensitive parameter which you can set to true.

Hi Mark,

Thanks for your message. Constructing a simple example to illustrate the point:

curl -X POST "http://localhost:9200/names/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
    "name" : "One name"
}
'

returns

{
  "_index" : "names",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}
curl -X POST "http://localhost:9200/names/_doc/2?pretty" -H 'Content-Type: application/json' -d'
{
    "name" : "Another name"
}
'

returns

{
  "_index" : "names",
  "_type" : "_doc",
  "_id" : "2",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 1,
  "_primary_term" : 1
}

Running a wildcard search:

curl -X GET "http://localhost:9200/names/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "wildcard": {
      "name": {
        "value": "Ano*"
      }
    }
  }
}
'

returns

{
  "took" : 59,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  }
}

whereas changing the wildcard query to be:

curl -X GET "http://localhost:9200/names/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "wildcard": {
      "name": {
        "value": "*"
      }
    }
  }
}
'

returns both documents as expected.

So my comment about case insensitivity still stands.
Try

curl -X GET "http://localhost:9200/names/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "wildcard": {
      "name": {
        "value": "ano*"
      }
    }
  }
}

or

curl -X GET "http://localhost:9200/names/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "wildcard": {
      "name": {
        "value": "Ano*",
        "case_insensitive": true
      }
    }
  }
}
'

Both of your queries returned one document:

{
  "took" : 99,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "names",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "name" : "Another name"
        }
      }
    ]
  }
}

With version 7.9.3, the value was allowed to be "Ano*" without the "case_insensitive": true. I will change the other wildcard queries to be case insensitive. Thanks for your help.

1 Like

Glad it worked out for you.

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