2

Hi I am using the not analyzed over the field

but when i search with the below query

 "query": {
    "query_string": {
      "query": "06H121605E",
      "default_field": "invoiceID"
    }
  }
}

I am getting 2 documents in results

but when I went for the wild card

its giving me hits as null

 "query": {
    "query_string": {
      "query": "06H121605*",
      "default_field": "invoiceID"
    }
  }

Here is my mapping for the invoiceID field

 "invoiceID": {
                  "type": "string",
                  "index": "not_analyzed"
               },

Query:

GET ordersdetails/_search
{
 "size": 1000, 
 "query": {
   "query_string": {
     "query": "06H121605E\\*",
     "default_field": "invoiceID",
     "analyze_wildcard": true
   }
 }
}

OUTPUT

{
   "took": 5,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 0,
      "max_score": null,
      "hits": []
   }
}

1 Answer 1

2

For the version 5.2.1 your query works you can as well use:

{
    "query": {
        "query_string" : { 
            "query" : "06H121605*",
            "default_field": "invoiceID",
            "analyze_wildcard": true
        }
    }
}

Here is the reference:

Documentation query string

Sign up to request clarification or add additional context in comments.

7 Comments

Hi Mel thanks for your remarks .!!!!! but in the second query m using the wildcard character *, for this m getting hit as null should I go for standard analyzer or index: not_analyzed in mapping
"query": { "query_string": { "query": "06H121605*", "default_field": "partNumber", "analyze_wildcard": true } }
Still using * in search term and analyze wild card : true combination is giving me hits as Null
Try to escape the * by doing \\* in your query
No luck with using escape sequence, Mel :(
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.