Elasticsearch:术语搜索不适用于特殊字符
Elasticsearch: Term search not working on special characters
我使用的是 Elasticsearch 最新版本 5.6.4。我想索引特殊字符并在其中搜索字段 title.special。以下是我的映射:
PUT index1
{
"mappings": {
"isContainer:false": {
"properties": {
"connectorSpecific": {
"properties": {
"title": {
"type": "text",
"store": true,
"fields": {
"special":{
"type": "text",
"analyzer": "special",
"search_analyzer": "special"
}
}
}
}
}
},
"settings": {
"index": {
"analysis": {
"analyzer": {
"special": {
"filter": [
"lowercase"
],
"tokenizer": "whitespace"
}
}
}
}
}
}
}
}
当我在 Kibana 中使用术语查询进行查询时,
GET index1/_search
{
"query": {
"term": {
"title.special": {
"value": "-unconstrained_net_use_inf_tw"
}
}
}
}
没有 return。但是当我进行匹配搜索时,文档会 return。例如
GET index1/_search
{
"query": {
"match": {
"title.special": {
"value": "-unconstrained_net_use_inf_tw"
}
}
}
}
我的映射有问题吗?如何使术语查询适用于 *、-、+ 等特殊字符。感谢任何帮助
术语查询适用于关键字数据类型。 title.special 是一个文本 datatype.to 要使术语查询有效,您必须更改 title.special 映射
看看这里,名为为什么术语查询不匹配我的文档的部分?
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html
我使用的是 Elasticsearch 最新版本 5.6.4。我想索引特殊字符并在其中搜索字段 title.special。以下是我的映射:
PUT index1
{
"mappings": {
"isContainer:false": {
"properties": {
"connectorSpecific": {
"properties": {
"title": {
"type": "text",
"store": true,
"fields": {
"special":{
"type": "text",
"analyzer": "special",
"search_analyzer": "special"
}
}
}
}
}
},
"settings": {
"index": {
"analysis": {
"analyzer": {
"special": {
"filter": [
"lowercase"
],
"tokenizer": "whitespace"
}
}
}
}
}
}
}
}
当我在 Kibana 中使用术语查询进行查询时,
GET index1/_search
{
"query": {
"term": {
"title.special": {
"value": "-unconstrained_net_use_inf_tw"
}
}
}
}
没有 return。但是当我进行匹配搜索时,文档会 return。例如
GET index1/_search
{
"query": {
"match": {
"title.special": {
"value": "-unconstrained_net_use_inf_tw"
}
}
}
}
我的映射有问题吗?如何使术语查询适用于 *、-、+ 等特殊字符。感谢任何帮助
术语查询适用于关键字数据类型。 title.special 是一个文本 datatype.to 要使术语查询有效,您必须更改 title.special 映射 看看这里,名为为什么术语查询不匹配我的文档的部分? https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html