当前位置: 首页 > elasticsearch, 搜索 > 正文

翻译 elasticsearch _all

关键字:
1 星2 星3 星4 星5 星 (1 次投票, 评分: 5.00, 总分: 5)
Loading ... Loading ...
baidu_share

原文地址:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-all-field.html

The idea of the _all field is that it includes the text of one or more other fields within the document indexed. It can come very handy especially for search requests, where we want to execute a search query against the content of a document, without knowing which fields to search on. This comes at the expense of CPU cycles and index size.

在建立文档索引时,_all field表示包含一个或多个field。特别是对于搜索请求,我们要对一个文件的内容执行搜索查询,不知道哪些字段搜索,用_all field就会很方便。但是也会花销cpu使用和增加索引量。

The _all fields can be completely disabled. Explicit field mapping and object mapping can be excluded / included in the _all field. By default, it is enabled and all fields are included in it for ease of use.

_all fields可以完全被禁止。明确某个field和对象映射可以被排除/包括在_all field。_all field允许包含所有的字段,很容易的使用。

When disabling the _all field, it is a good practice to set index.query.default_field to a different value (for example, if you have a main “message” field in your data, set it to message).
禁止使用_all field,它是一个很好的做法在设置index.query.default_field 为一个不同值(例如:在你的数据中有一个主要的”message” field,你可以设定message 为默认的field)。

One of the nice features of the _all field is that it takes into account specific fields boost levels. Meaning that if a title field is boosted more than content, the title (part) in the _all field will mean more than the content (part) in the _all field.

_all field有一个很好的特性是,它需要考虑到特定field 的boost,可以提高其boost的值。意味着标题的boost要高于content的boost,标题(部分)在_all field中要高于内容(部分)在_all field。

Here is a sample mapping:
这是一个简单映射:

{
    "person" : {
        "_all" : {"enabled" : true},
        "properties" : {
            "name" : {
                "type" : "object",
                "dynamic" : false,
                "properties" : {
                    "first" : {"type" : "string", "store" : "yes", "include_in_all" : false},
                    "last" : {"type" : "string", "index" : "not_analyzed"}
                }
            },
            "address" : {
                "type" : "object",
                "include_in_all" : false,
                "properties" : {
                    "first" : {
                        "properties" : {
                            "location" : {"type" : "string", "store" : "yes", "index_name" : "firstLocation"}
                        }
                    },
                    "last" : {
                        "properties" : {
                            "location" : {"type" : "string"}
                        }
                    }
                }
            },
            "simple1" : {"type" : "long", "include_in_all" : true},
            "simple2" : {"type" : "long", "include_in_all" : false}
        }
    }
}

The _all fields allows for store, term_vector and analyzer (with specific index_analyzer and search_analyzer) to be set.
_all fields允许存储,term_vector和分词(指定index_analyzer和search_analyzer)

highlighting高亮

For any field to allow highlighting it has to be either stored or part of the _source field. By default _all field does not qualify for either, so highlighting for it does not yield any data.

任何字段允许高亮的条件是它必须存储或是_source 字段的一部分。默认情况下_all field不符合高亮,所以无论是高亮它不会产生任何数据。

Although it is possible to store the _all field, it is basically an aggregation of all fields, which means more data will be stored, and highlighting it might produce strange results.

虽然它可以存储在_all字段中,它基本上是一个聚合的所有字段,那就意味着更多的数据需要被存储,并使它高亮可能会产生奇怪的结果。

本文固定链接: http://www.chepoo.com/translate-elasticsearch-_all.html | IT技术精华网

翻译 elasticsearch _all:等您坐沙发呢!

发表评论