Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use Eleasticsearch query_string wildcards for the the key

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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

creditScoreTenantResults.\*.creditScore:{10 TO *}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading