简体   繁体   中英

How do I search for a “-” in a field value in kibana?

Here is the mapping for this field:

"username": {
  "type": "text",
  "norms": false,
  "fields": {
    "keyword": {
      "type": "keyword"
    }
  }
},

I have a field that occasionally has the value of "-": 在此处输入图片说明

I clicked "filter for value" and this is the filter it created: 在此处输入图片说明

But when I do searches for this value it says not results found.

How do I escape the "-"?

I tried "\\-" but no dice

I tried check if the value "exists" as suggested but this also returns 0 results: 在此处输入图片说明

Also tried !(_exists_:"username") in the kibana search bar and that also returns 0 results.

Also running (_exists_:"username") included docs with and without a value for the username field

I also tried this which returns 0 results:

(_missing_:"username")

As your username field is of text type and analyzed with standard analyzer , the inverted index will have no tokens for username where as username.keyword is of keyword type it will have the exact value - in inverted index.

You can search it in following ways:

  1. From Kibana search bar:

    username.keyword: "-"

  2. From Kibana filter:

    { "term": { "username.keyword": "-" } }

  3. From Sense plugin:

    GET _search { "query": { "term": { "username.keyword": "-" } } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM