Elasticsearch映射无法使用数字

时间:2018-06-11 15:06:57

标签: java elasticsearch kibana elastic-stack

我写了弹性搜索mapping,它只用于字母表。如何对数值进行相同的操作。

PUT /documents_test8
{
   "settings" : {
      "analysis" : {
         "analyzer" : {
            "filename_search" : {
               "tokenizer" : "filename",
               "filter" : ["lowercase"]
            },
            "filename_index" : {
               "tokenizer" : "filename",
               "filter" : ["lowercase","edge_ngram"]
            }
         },
         "tokenizer" : {
            "filename" : {
               "pattern" : "[^\\p{L}\\d]+",
               "type" : "pattern"
            }
         },
         "filter" : {
            "edge_ngram" : {
               "side" : "front",
               "max_gram" : 20,
               "min_gram" : 1,
               "type" : "edgeNGram"
            }
         }
      }
   },
   "mappings" : {
      "doc" : {
         "properties" : {
            "filename" : {
               "type" : "text",
               "search_analyzer" : "filename_search",
               "index_analyzer" : "filename_index"
            }
         }
      }
   }
}

1 个答案:

答案 0 :(得分:0)

对于数字,您可以使用键入" long"

来定义这样的映射
"type": "long"

对于浮点数,请使用类型作为" float"

"type": "float"