如何通过Elasticsearch分析数字?

时间:2018-05-15 12:24:10

标签: elasticsearch

我有一些这样的数据:

{"date": "2018-04-29T00:36", "price": 11900, "sellerName": "Leif J", "description": "Nybesiktigad U.A 2018-04-28 vid 2291mil. 360 mil p\u00e5 senaste 6 \u00e5ren. Ej vinterk\u00f6rd, och varmgarage p\u00e5 varje vinterf\u00f6rvaring (i min \u00e4go.) Extra ut\u00f6ver standard: -Eluppv\u00e4rmda handtag (2l\u00e4ges) -LED lampor -Avtagbar packbox. -TK Hydrotech avgassystem (ca 10% effekt) L\u00e4nkar nedan: https://www.youtube.com/watch?v=vqa_AiNq8-4 http://www.turbokit.net/#sthash.MboS0Bf2.dpbs L\u00e4s g\u00e4rna Expressens omd\u00f6me* f\u00f6r mer info (*fel i artikeln=varvr\u00e4knare finnes) https://www.expressen.se/motor/tester/en-fatolj-pa-hjul/ Billig i skatt / f\u00f6rs\u00e4kring / drift. Kymco, Grand Dink, 150, Scooter, Maxi, Maxiscooter, Vespa, Piaggio", "location": "Malm\u00f6, Sydv\u00e4st", "id": 0, "title": "Kymco Grand Dink 250", "modelYear": 2002, "url": "https://www.blocket.se/malmo/Kymco_Grand_Dink_250_79092265.htm?ca=11&w=3", "vehicleType": "Scooter"}}

如您所见,pricemodelYear字段是数字。如果我使用默认设置索引此文档,似乎Elasticsearch会自动识别这些字段是数字。像这样:

POST _search:

{
    "query": {
        "bool": {
            "must": {
                "multi_match": {
                    "fields": [
                        "title^1.0",
                        "description"
                    ],
                    "operator": "or",
                    "query": "honda",
                    "type": "cross_fields"
                }
            }
        }
    }
}

返回:

        {
            "_index": "simple",
            "_type": "motorcycle",
            "_id": "XZu-Y2MByJQ0ZKmCDVzt",
            "_score": 4.3209167,
            "_source": {
                "date": "2018-03-28T00:00",
                "price": 67900,
                "sellerName": "Honda Mc Center Vänersborg",
                "description": "Honda VFR800A Mätarställning: 2800 mil Färg: Svartmetallic Typ: Touring/Landsväg Info: en härlig v-fyra i bra skick, Nyservad, värmehandtag, däck ok, GIVI väskor, Top box Oxford Honda, Honda VFR, VFR, VFR 800, Honda touring, Honda sport touring, Touring, Bankörning, banhoj",
                "location": "Vänersborg",
                "id": 13561,
                "title": "Honda VFR800A",
                "modelYear": 2008,
                "url": "https://www.blocket.se/alvsborg/Honda_VFR800A_78000747.htm?ca=11&w=3",
                "vehicleType": "Touring"
            }
        }

数字字段周围没有引号,因此它们似乎是数字。我的问题是,数字字段如何分析,如果有的话?我找不到任何关于Elasticsearch识别字段是数字的过程的文档,然后在索引该字段时执行什么类型的分析。

有人能告诉我在哪里可以读到这个吗?

1 个答案:

答案 0 :(得分:1)

我不完全确定我理解这个问题,但是文档中的字段是打字的 - Elasticsearch没有识别字段&#39;它们是在索引级别定义的。< / p>

Official docs

修改:您的索引可能是自动创建的,因此您正在寻找的是dynamic field mapping.