弹性搜索1排序

时间:2014-07-07 09:12:17

标签: sorting elasticsearch

我将弹性搜索从0.9升级到当前版本" 1.2"。看来排序是不同的。当我设置字段ES应排序时,似乎ES匹配并按文本中的数字排序:

{
  "from": 0,
  "size": 100,
  "sort": {"title": "asc"},
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "and": {
          "filters": [
            {
              "term": {
                "entityBase": 1
              }
            }
          ]
        }
      }
    }
  }
}

其中一些结果:

{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 10,
        "successful": 10,
        "failed": 0
    },
    "hits": {
        "total": 12,
        "max_score": null,
        "hits": [
            {
                "_index": "ibyenintegrationtest",
                "_type": "entity",
                "_id": "4",
                "_score": null,
                "_source": {
                    "id": 4,
                    "entityVersion": 0,
                    "entityBase": 1,
                    "title": "Zoologisk Have 123",
                    "created": "2014-07-07T10:06:56.0757324+02:00",
                    "categories": [
                        "otherplace"
                    ],
                    "tags": [],
                    "prices": {
                        "average": -1,
                        "lower": 0,
                        "upper": 1.7976931348623157e+308
                    },
                    "locations": [
                        {
                            "id": 4,
                            "name": "Zoologisk Have 123"
                        }
                    ],
                    "articleReferences": [],
                    "bookingTypes": []
                },
                "sort": [
                    "123"
                ]
            },
            {
                "_index": "ibyen",
                "_type": "entity",
                "_id": "94813",
                "_score": null,
                "_source": {
                    "id": 94813,
                    "entityVersion": 1,
                    "entityBase": 1,
                    "title": "3 parker i København",
                    "created": "2014-04-25T03:30:15.5133281+02:00",
                    "categories": [
                        "otherplace"
                    ],
                    "tags": [],
                    "prices": {
                        "average": -1,
                        "lower": 0,
                        "upper": 1.7976931348623157e+308
                    },
                    "locations": [
                        {
                            "id": 94813,
                            "name": "3 parker i København",
                            "geoPoint": {
                                "lat": 55.6760968,
                                "lon": 12.5683371
                            },
                            "streetName": "Øster Voldgade",
                            "zipCode": "1350",
                            "city": "København K",
                            "district": "indre-by"
                        }
                    ],
                    "articleReferences": [],
                    "bookingTypes": []
                },
                "sort": [
                    "3"
                ]
            },
...

在文档中真的看不出这是排序应该如何工作,或者我如何定义不匹配文本中的数字。

1 个答案:

答案 0 :(得分:0)

对该字段进行了分析,因此它被标记化了。

查看映射(默认为分析)