Search query builder and mapping

Hello everyone,

I inherited the mapping of a service (JAVA SPRING BOOT)with Elasticsearch and I'm going crazy for the search.

my field is so mapped:


con questo analyzer:

    "analysis": {
      "analyzer": {
        "k_analyzer": {
          "tokenizer": "standard",
          "filter": [

with innerBool.should(QueryBuilders. ........),
I can't make the exact match: if I have energy and green energy
if I search for "energy" both come up, how can I map my field in such a way that if I search for "eng" both come up and if I search for "energy" only energy comes out?


Without much details of the purpose I might suggest the wildcard query.
Do you use this partial search to perform the autocomplete? In that case there are other options.

I tried with the wildcard *energy*

but so I get 2 records, energy and blue energy, I want that if I write energy, only energy comes out.
I can't find a valid option, do you know any?

Try this:

POST your_index/_doc
{"organizationNames":"green energy"}

POST your_index/_doc

GET your_index/_search
  "query": {
    "wildcard": {
      "organizationNames.keyword": {
        "value": "ener*"

Keep in mind that wildcards can experience performance degradations.

Avoid beginning patterns with * or ?. This can increase the iterations needed to find matching terms and slow search performance.

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