J.Done
J.Done

Reputation: 3053

elasticsearch wildcard string search query with '>'

I have string field that mapped as 'not_analyzed'. Each string has '>' simbol and need to find some string with it.

string e.g)

one>two>tree>four>...

with below query, I could get result I expected.

"query": { "wildcard": { "activityseq": { "value": "one*" } } }

but when added '>' in value, It's not.

"query": { "wildcard": { "activityseq": { "value": "one>*" } } }

or

"query": { "wildcard": { "activityseq": { "value": "one>*" } } }

Any Idea of this?


document sample

{ "_index": "pm", "_type": "dmcase_00090", "_id": "AVQ7Wjht0bpb6L5Mykw7", "_version": 1, "_score": 1, "_source": { "endat": "1970-01-12T06:08:00+09:00", "startat": "1970-01-06T23:02:00+09:00", "activityseq": "MakeTicket>FirstContact>ArrangeSurvey>MakeTicket>InformClientSurvey>ArrangeSurvey>Survey>Survey>InternRepair>RepairReady>InternRepair>SendTicketToFinAdmin>TicketReady>ReadyInformClient", "events": [ { ... some events


query + result

1.

"query": { "wildcard": { "activityseq": { "value": "maketicket*" } } }

result : data as I expect

2.

"query": { "wildcard": { "activityseq": { "value": "maketicket>*" } } }

result

"hits": { "total": 0, "max_score": null, "hits": [] }

3.

"query": { "wildcard": { "activityseq.raw": { "value": "maketicket*" } } }

result

"hits": { "total": 0, "max_score": null, "hits": [] }

4.

"query": { "wildcard": { "activityseq": { "value": "maketicket>*" } } }

result

"caused_by": { "type": "json_parse_exception", "reason": "Unrecognized character escape '>' (code 62)\n at [Source: [B@61201912; line: 5, column: 37]" }

Upvotes: 0

Views: 1429

Answers (1)

Val
Val

Reputation: 217394

Your query needs to look like this and it will work, i.e. you need to match on the seqstring.raw sub-field, since that's the one which is not_analyzed

{
  "query": {
    "wildcard": {
      "seqstring.raw": {
        "value": "one>*"
      }
    }
  }
}

Upvotes: 1

Related Questions