使用 dmesg 来查看一些硬件或驱动程序的信息或问题。

增加一个字段,改变文档格式后,搜索不出

Elasticsearch | 作者 wstorm | 发布于2017年05月08日 | 阅读数:3089

我的elasticsearch中有一个index,index名字是my_index, index中有一个type, 名字是my_type, my_type中有两个document, 他们都是有3个字段,分别是name, address, id, 现在我往my_type里面又增加了一个document, 但是它包含4个字段, name, address, id和sex,英文mapping是动态的,这个时候mapping就自动增加了一个sex,也变成了4个字段。 现在我想用elasticsearch的API用sex的条件搜索出这个document,但是不返回结果。
然后我就又尝试把只有3个字段的两个document都加上了sex字段,这样所有的documen格式就都是一样的了, 可是,还是搜索不出结果,如果我用原来就存在的字段, 比如name作为条件去搜索,就可以, 请问大侠, 我这是哪里不对呢?
已邀请:

xupiao

赞同来自:

能把你最新的map 结构 贴出来吗

wstorm

赞同来自:

xupiao 您好, 
 
这是mapping结构, 
 
 
{"igf": {

"mappings": {

"invoice": {

"_timestamp": {

"enabled": true

},
"properties": {

"HEADER": {

"properties": {

"APPROVALNUMBER": {

"type": "string",
"index": "not_analyzed"

},
"BRANCHSUPPLIERCODE": {

"type": "string"

},
"BRANCHSUPPLIERCODE1": {

"type": "string"

},
"CONTRACTNUMBER": {

"type": "string",
"index": "not_analyzed"

},
"CORPORATESUPPLIERCODE": {

"type": "string",
"index": "not_analyzed"

},
"DEALERACCOUNTID": {

"type": "string"

},
"DEALERCODE": {

"type": "string",
"index": "not_analyzed"

},
"FINANCIER": {

"type": "string",
"index": "not_analyzed"

},
"INVOICEDATE": {

"type": "date",
"format": "strict_date_optional_time||epoch_millis"

},
"INVOICENUMBER": {

"type": "string",
"index": "not_analyzed"

},
"INVOICETYPE": {

"type": "string",
"index": "not_analyzed"

},
"MACHINENUMBER": {

"type": "string",
"index": "not_analyzed"

},
"ORDERNUMBER": {

"type": "string",
"index": "not_analyzed"

},
"PONUMBER": {

"type": "string",
"index": "not_analyzed"

}

}

},
"INVOICEID": {

"type": "string",
"index": "not_analyzed"

}

}

}

}

}}
 
 
 
 
 
-------------------------------------
 
"BRANCHSUPPLIERCODE": {

"type": "string"

}, 这个自动加上去的, 因为我新的数据增加了BRANCHSUPPLIERCODE这个字段, 我注意到它没有定义index,
其他字段是这样的,例如:
"PONUMBER": {

"type": "string",
"index": "not_analyzed"

}
 
我觉得可能没有index就默认成no了,
有没有什么办法可以让自动加上的新字段的mapping带上这个呢 ? "index": "not_analyzed"
 
谢谢

要回复问题请先登录注册