elasticsearch 如何使用关键字分析器进行搜索?
我将关键字分析器作为默认分析器,如下所示:
elasticsearch 如何使用关键字分析器进行搜索?,
elasticsearch,
elasticsearch,我将关键字分析器作为默认分析器,如下所示: { "settings": { "index": { "analysis": { "analyzer": { "default": { "type": "keyword" }}}}}} ``` 但现在我什么都找不到了。e、 g: { "query": { "query_string": { "query": "cast" }}} 尽管“cas
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"default": {
"type": "keyword"
}}}}}}
```
但现在我什么都找不到了。e、 g:
{
"query": {
"query_string": {
"query": "cast"
}}}
尽管“cast”是索引文档中的常用值,但结果为0。()
搜索“*”工程罚款顺便说一句
我的映射中只有显式默认值:
{
"oceanography_point": {
"_all" : {
"enabled" : true
},
"properties" : {}
}
}
索引的行为就像没有字段包含在_all中一样,因为field:value查询工作正常
我是否误用了关键字分析器?使用关键字分析器,您只能进行精确的字符串匹配。 假设您使用了关键字分析器,但没有使用过滤器。 在这种情况下,对于索引为“castawayinforest”的字符串,搜索“Cast”或“away”都不起作用。你需要做一个精确的“丢弃在森林中”字符串来匹配它。(假设没有使用小写筛选器,您也需要给出正确的大小写) 更好的方法是将一个副本声明为关键字分析副本,另一个声明为正常副本。
您可以在其中一个字段上搜索,在另一个字段上聚合。好的,经过15小时的反复试验,我可以得出结论,这对搜索是有效的:
{
"settings": {
"index": {
"analysis": {
"tokenizer": {
"default": {
"type": "keyword"
}}}}}}
这是如何打破刻面的,因此我最终使用了动态模板:
"dynamic_templates" : [
{
"strings_not_analyzed" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
],
是的,我知道还有其他实现文本搜索的方法,但是在这种情况下“cast”是完全匹配的。你能粘贴*的结果吗?没有太多要粘贴的内容,我得到一个hits数组,其中包含我的后台couchdb数据库中的所有文档。我想看看原始数据是什么样子。在模式中,您是否禁用了集合的_all或将集合的“include_in_all”设置为false?