Does Elasticsearch keep an order of multi-value fields?

前端 未结 2 1639
日久生厌
日久生厌 2020-12-20 02:38

Does Elasticsearch keep an order of multi-value fields?

I.e. if I\'ve put following values into fields:

{
    \"values\": [\"one\", \"two\", \"three\         


        
相关标签:
2条回答
  • 2020-12-20 03:10

    I found out the answer.

    Yes, I can rely on Elasticsearch to keep an order of values in multivalue field within a document. (However, when I am performing a search, there is no information available to Elasticsearch about at what position certain term was).

    According to documentation:

    When you get a document back from Elasticsearch, any arrays will be in the same order as when you indexed the document. The _source field that you get back contains exactly the same JSON document that you indexed.

    However, arrays are indexed—made searchable—as multivalue fields, which are unordered. At search time, you can’t refer to “the first element” or “the last element.” Rather, think of an array as a bag of values.

    https://www.elastic.co/guide/en/elasticsearch/guide/current/complex-core-fields.html#_multivalue_fields

    0 讨论(0)
  • 2020-12-20 03:33

    Elasticsearch - The Definitive Guide says the following:

    When you get a document back from Elasticsearch, any arrays will be in the same order as when you indexed the document. The _source field that you get back contains exactly the same JSON document that you indexed.

    However, arrays are indexed—made searchable—as multivalue fields, which are unordered. At search time, you can’t refer to “the first element” or “the last element.” Rather, think of an array as a bag of values.

    So it seems that for stored fields order is preserved, for indexed fields it's not.

    0 讨论(0)
提交回复
热议问题