简体   繁体   English

如何在弹性搜索中忽略空格

[英]How to ignore whitespaces in elastic search

In Elasticsearch, I have a field called "address", in that field data is indexed as 在Elasticsearch中,我有一个名为“地址”的字段,在该字段中,数据被索引为

"322 Wall       Tax    Road"

In between each words multiple spaces have been added. 在每个单词之间添加了多个空格。 So while searching for "322 Wall Tax Road" does not returning data. 因此,在搜索“ 322 Wall Tax Road”时不会返回数据。

is there any way to ignore additional whitespaces without reindexing. 有什么方法可以忽略其他空格而无需重新索引。 Thank you. 谢谢。

This is my current mapping 这是我当前的映射

"mappings": {
"esiid": {
"properties": {
"address": {
  "type": "string",
  "index": "not_analyzed"
},
"city": {
  "type": "string"
},

"zip": {
  "type": "string"
}
}
}

只用一个空格替换双空格怎么办?

$workedString = str_replace("  "," ",$yourString);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM