Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Mar 16, 2015
1 parent c92a921 commit db3b18e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 46 deletions.
11 changes: 0 additions & 11 deletions 052_Mapping_Analysis/45_Mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ GET /gb/_mapping/tweet
### 自定义字段映射

The most important attribute of a field is the `type`. For fields
other than `string` fields, you will seldom need to map anything other
than `type`:

映射中最重要的字段参数是`type`。除了`string`类型的字段,你可能很少需要映射其他的`type`

```javascript
Expand All @@ -91,7 +87,6 @@ than `type`:

对于`string`字段,两个最重要的映射参数是`index``analyer`

===== `index`
### `index`

`index`参数控制字符串以何种方式被索引。它包含以下三个值当中的一个:
Expand All @@ -117,12 +112,6 @@ than `type`:
### 分析

For `analyzed` string fields, use the `analyzer` attribute to
specify which analyzer to apply both at search time and at index time. By
default, Elasticsearch uses the `standard` analyzer, but you can change this
by specifying one of the built-in analyzers, such as
`whitespace`, `simple`, or `english`:

对于`analyzed`类型的字符串字段,使用`analyzer`参数来指定哪一种分析器将在搜索和索引的时候使用。默认的,Elasticsearch使用`standard`分析器,但是你可以通过指定一个内建的分析器来更改它,例如`whitespace``simple``english`

```javascript
Expand Down
52 changes: 18 additions & 34 deletions 052_Mapping_Analysis/50_Complex_datatypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,35 @@
{ "tag": [ "search", "nosql" ]}
```

对于数组不需要特殊的映射。任何一个字段可以包含零个、一个或多个值,同样对于全文字段被分析产生多个词
对于数组不需要特殊的映射。任何一个字段可以包含零个、一个或多个值,同样对于全文字段将被分析并产生多个词

言外之意,这意味着**数组中所有值必须为同一类型**。你不能把日期和字符窜混合。如果你创建一个新字段,这个字段索引了一个数组,Elasticsearch将使用第一个值的类型来确定这个新字段的类型。

****
当你从Elasticsearch中取回一个文档,任何一个数组的顺序和你索引它们的顺序一致。你取回的`_source`字段的顺序同样与索引它们的顺序相同。

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 multi-value 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_.

****
然而,数组是做为多值字段被**索引**的,它们没有顺序。在搜索阶段你不能指定“第一个值”或者“最后一个值”。倒不如把数组当作一个**值集合(gag of values)**

==== Empty fields
### 空字段

Arrays can, of course, be empty. This is the equivalent of having zero
values. In fact, there is no way of storing a `null` value in Lucene, so
a field with a `null` value is also considered to be an empty
field.
当然数组可以是空的。这等价于有零个值。事实上,Lucene没法存放`null`值,所以一个`null`值的字段被认为是空字段。

These four fields would all be considered to be empty, and would not be
indexed:
这四个字段将被识别为空字段而不被索引:

[source,js]
--------------------------------------------------
```javascript
"empty_string": "",
"null_value": null,
"empty_array": [],
"array_with_null_value": [ null ]
--------------------------------------------------
```

[[inner-objects]]
==== Multi-level objects
### 多层对象

The last native JSON datatype that we need to discuss is the _object_
-- known in other languages as hashes, hashmaps, dictionaries or
associative arrays.
我们需要讨论的最后一个自然JSON数据类型是**对象(object)**——在其它语言中叫做hashed、hashmaps、dictionaries 或者 associative arrays.

_Inner objects_ are often used to embed one entity or object inside
another. For instance, instead of having fields called `user_name`
and `user_id` inside our `tweet` document, we could write it as:
**内部对象(inner objects)**经常用于嵌入一个实体或对象里的另一个地方。例如,做在`tweet`文档中`user_name``user_id`的替代,我们可以这样写:

[source,js]
--------------------------------------------------
```javascript
{
"tweet": "Elasticsearch is very flexible",
"user": {
Expand All @@ -70,10 +52,10 @@ and `user_id` inside our `tweet` document, we could write it as:
}
}
}
--------------------------------------------------
```


==== Mapping for inner objects
### 内部对象的映射

Elasticsearch will detect new object fields dynamically and map them as
type `object`, with each inner field listed under `properties`:
Expand Down Expand Up @@ -106,8 +88,8 @@ type `object`, with each inner field listed under `properties`:
}
}
--------------------------------------------------
<1> Root object.
<2> Inner objects.
<1> 根对象.
<2> 内部对象.

The mapping for the `user` and `name` fields have a similar structure
to the mapping for the `tweet` type itself. In fact, the `type` mapping
Expand All @@ -116,6 +98,8 @@ _root object_. It is just the same as any other object, except that it has
some special top-level fields for document metadata, like `_source`,
the `_all` field etc.

`user``name`字段的映射与`tweet`类型自己很相似。事实上,`type`映射只是`object`映射的一种特殊类型,

==== How inner objects are indexed

Lucene doesn't understand inner objects. A Lucene document consists of a flat
Expand Down
2 changes: 1 addition & 1 deletion 054_Query_DSL/55_Request_body_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ POST /_search

我们将在后续的章节中讨论聚合查询,但是现在我们把关注点仅放在查询语义上。

相对于神秘的查询字符串方法,请求体查询允许我们使用结构化查询Query DSL(Query Domain Specific Language)
相对于神秘的查询字符串方法,请求体查询允许我们使用结构化查询Query DSL(Query Domain Specific Language)

0 comments on commit db3b18e

Please sign in to comment.