【发布时间】:2014-11-04 17:02:58
【问题描述】:
当我查询 _all 字段的数据时,Elasticsearch 返回两个文档(文档中都只有一个字段)。但是,当我执行相同的查询时,除了将要查询的字段从 _all 更改为返回文档中某个字段的名称之外,Elasticsearch 什么也不返回。这似乎发生在query_string 查询以及此处显示的match 查询中。任何想法这是发生了什么以及如何解决它?
这是映射
analyzertestpatternsemi: {
mappings: {
content: {
properties: {
field: {
type: string
store: true
term_vector: with_positions_offsets
index_analyzer: analyzer_name
}
field2: {
type: string
store: true
index_analyzer: analyzer_name
}
}
}
}
}
这是设置
{
analyzertestpatternsemi: {
settings: {
index: {
uuid: _W55phRKQ1GylWU5JleArg
analysis: {
analyzer: {
whitespace: {
type: custom
fields: [
lowercase
]
tokenizer: whitespace
}
analyzer_name: {
preserve_original: true
type: pattern
pattern: ;
}
}
}
number_of_replicas: 1
number_of_shards: 5
version: {
created: 1030299
}
}
}
}
}
文档
{
_index: analyzertestpatternsemi
_type: content
_id: 3
_version: 1
found: true
_source: {
field2: Hello, I am Paul; George
}
}
和
{
_index: analyzertestpatternsemi
_type: content
_id: 2
_version: 1
found: true
_source: {
field: Hello, I am Paul; George
}
}
获取_id 的词向量给出
george 和 hello, i am paul
“_all”查询
curl -XGET http://localhost:9200/analyzertestpatternsemi/_search?
{
"query": {
"bool": {
"must": [
{
"match": {
"_all": {
"query": "george",
"type": "phrase"
}
}
}
]
}
}
}
“所有”查询结果
{
took: 2
timed_out: false
_shards: {
total: 2
successful: 2
failed: 0
}
hits: {
total: 2
max_score: 0.4375
hits: [
{
_index: analyzertestpatternsemi
_type: content
_id: 2
_score: 0.4375
_source: {
field: Hello, I am Paul; George
}
}
{
_index: analyzertestpatternsemi
_type: content
_id: 3
_score: 0.13424811
_source: {
field2: Hello, I am Paul; George
}
}
]
}
}
*** 相同的查询,但在字段中搜索:“字段”
curl -XGET http://localhost:9200/analyzertestpatternsemi/_search?
{
"query": {
"bool": {
"must": [
{
"match": {
"field": {
"query": "george",
"type": "phrase"
}
}
}
]
}
}
}
“字段”查询结果
{
took: 0
timed_out: false
_shards: {
total: 5
successful: 5
failed: 0
}
hits: {
total: 0
max_score: null
hits: [ ]
}
}
相同的查询,但在字段中搜索:“field2”
curl -XGET http://localhost:9200/analyzertestpatternsemi/_search?
{
"query": {
"bool": {
"must": [
{
"match": {
"field2": {
"query": "george",
"type": "phrase"
}
}
}
]
}
}
}
“field2”查询结果
{
took: 0
timed_out: false
_shards: {
total: 5
successful: 5
failed: 0
}
hits: {
total: 0
max_score: null
hits: [ ]
}
}
【问题讨论】:
标签: elasticsearch field return-value analyzer