Home > database >  How to use Eleasticsearch query_string wildcards for the the key
How to use Eleasticsearch query_string wildcards for the the key

Time:03-25

inside of a document that I indexed in Elasticsearch contains an array, it looks like the following.

 "creditScoreTenantResults.123456789X.creditScore": [
    73.72
  ],
  "creditTenants.address.country.keyword": [
     "country1"
  ],
  "creditScoreTenantResults.123456789X.personalId.keyword": [
     "123456789X"
  ],
  "creditUuid.keyword": [
     "9d7ba281-2602-42f7-aae7-40c802ede21c"
  ],

and I implemented the following query.

POST http://localhost:56677/csm/_search?pretty
Content-Type: application/json

{
   "query": {
      "query_string": {
         "query": "creditScoreTenantResults.123456789X.creditScore :>10"
       }
    },
    "fields": ["*"]
}

which works perfectly but actually the question I like to ask, actually is more like 'give me all credit scores bigger then 10', so I converted the query string to 'creditScoreTenantResults.*.creditScore :>10' while I read in the following post that it should work.

Unfortunately Elasticsearch reporting a Parsing Exception, complaining with the wildcard version it can recognise ':' from ':>10', is the post I mentioned correct? Is this query possible at all?

If yes, how can I formulate it?

PS. I am using Elasticsearch 7.16, may be it is not possible with it and I have to use ES8?

Thx for answers.

CodePudding user response:

The query_string query uses the Lucene query language, so your range condition should be like this:

creditScoreTenantResults.\*.creditScore:{10 TO *}
  • Related