弹性搜索将仅在空格后显示正确的数据

时间:2018-10-19 11:11:57

标签: elasticsearch elastic-stack

我正在使用以下映射模板映射弹性索引。

PUT _template/template_1
{
    "index_patterns": [
      "ubq-*"
    ],
    "settings": {
      "index": {
        "analysis": {

          "analyzer": {
            "my_analyzer": {
              "filter": [
                "lowercase"


              ],
              "type": "custom",
              "tokenizer": "keyword",
              "remove_trailing": "false"
            }
          }
        },
        "number_of_shards": "1"
      }
    },
    "mappings": {
      "doc": {
        "properties": {
          "Index": {
            "type": "float",
            "index": "true"
          },
          "Category": {
            "type": "keyword",
            "index": "true"
          },
          "Scat": {
            "type": "keyword",
            "index": "true"
          },
          "Sscat": {
            "type": "keyword",
            "index": "true"
          },
          "Products": {
            "type": "text",
            "index": "true",
            "analyzer": "my_analyzer"
          },
          "Measure": {
            "type": "keyword",
            "index": "true"

          },
          "Price": {
            "type": "float",
            "index": "true"
          },
          "Description": {
            "type": "keyword",
            "index": "true"

          },
          "Gst": {
            "type": "float",
            "index": "true"
          },
          "Url": {
            "type": "keyword",
            "index": "true"

          }
        }
      }
    },
    "aliases": {}
  }

当我对索引执行搜索时,会得到随机结果。

enter image description here

但是,当我在搜索词后留出空格时,我会得到预期的结果。

enter image description here

1)如何解决此问题,以便在没有空格的情况下获得正确的结果?

2)如果我提供随机输入,elastic仍在获取一些数据,如果在索引中找不到弹性,我如何确保elastic不获取任何数据?

0 个答案:

没有答案