Skip to content

[SearchBar] Field value selection doesn't work on keyword fields by default #6217

@PhaedrusTheGreek

Description

@PhaedrusTheGreek

When using SearchBar filters such as:

{
      type: 'field_value_selection',
      field: 'type',
      name: 'Type',
      multiSelect: 'or',
      cache: 10000,
      options
    },

Or a query such as type:(elasticsearch or logstash) will generate ES Query DSL match query:

 "bool": {
    "must": [
        {
            "match": {
                "type": {
                    "query": "elasticsearch logstash",
                    "operator": "or"
                }
            }
        }
    ]
}

However the above query will not work if the type field is a keyword.

  • Typically keywords are used as filters, since they are explicit
  • The keyword field analyzer won't tokenize elasticsearch logstash, and so the only valid match is exactly that.

I did notice that toESQuery has options.fieldValuesToAndQuery, which should provide a workaround

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions