elasticsearch index type

来源:互联网 发布:梦幻西游数据账号货源 编辑:程序博客网 时间:2024/05/21 09:35

shay.banon 对于type的解释

Index names are different indices. Types are just syntactic sugar to add separation between types of documents. If you know Lucene, type is just a field on a doc.


Let me explain a bit how types work in elasticsearch. At the end of the day, Lucene index has Documents and has no notion of types. Types are something added (as best as possible) by elasticsearch. A lucene document is a flat structure key value pair (so objects in json are also translated to this), and a type ends up as another field within the document (called _type).


Then you build a query and in the field (any query that acces a field to execute on), you can specify type1.field1, and in this case, it will be automatically detected, and the query will be wrapped to only be executed match on docs with _type:type1 (in an efficient manner), on field1.


This does mean that across types, having the same field name with different mappings types (for example, type1 has field1 of type numeric, and type2 also has field1 but of type string) should not be done (working on automatically detecting that...).

So, the type prefix when you define the field name should allow to only search on a field against that specific type. (At the end of the day, it is wrapped in a filtered query with a _type:type1 term filter).

-shay.banon
这里只是做了一个整理便于查看。
相关的网址:
http://elasticsearch-users.115913.n3.nabble.com/ElasticSearch-and-doc-type-td2783692.html
http://elasticsearch-users.115913.n3.nabble.com/Searching-across-types-td1745420.html#a1749010

type 的应用示例:

http://www.elasticsearch.org/blog/2010/02/12/yourdatayoursearch.html


原创粉丝点击