Home > Software design >  Kibana search pattern issue
Kibana search pattern issue

Time:10-22

I am trying to create a elastic search query for one of my Library projects. I am trying to use regex but I do not get any result. I am trying to enter the following regex query.

GET /manifestation_v1/_search
{
  "query": {
    "regexp": {
      "bibliographicInformation.title": {
        "value": "python access*"
      }
    }
  }
}

access is a wildcard so i want to create a query which takes as python access* not python access

Can anyone help me out who already has some experience in kibana?

CodePudding user response:

you can try wildcard query

{
  "query": {
          "wildcard": {
            "bibliographicInformation.title": {
              "value": "saba safavi*"
            }
          }
        }

}

CodePudding user response:

You need to run regex query on keyword field and use .* instead of *

ex.

GET /manifestation_v1/_search
{
  "query": {
    "regexp": {
      "bibliographicInformation.title": {
        "value": "python access.*"
      }
    }
  }
}

Regex is slower , you can also try prefix query

{
  "query": {
    "prefix": {
      "bibliographicInformation.title": {
        "value": "python access"
      }
    }
  }
}

If field is of nested type then you need to use nested query

Update

For "text" type , field is stored as tokens. i.e "python access" is stored as ["python","access"]. You query is trying to match "phython access*" with each of these tokens individually. You need to query against keyword field , which is stored as single value "phython access".

  • Related