5

我刚刚安装并测试了弹性搜索,它看起来很棒,我需要知道一些我有配置文件的东西

elasticsearch.jsonconfig目录中

{    
"network" : {
    "host" : "127.0.0.1"
},
"index" : {
    "number_of_shards": 3,
    "number_of_replicas": 1,
    "refresh_interval" : "2s",        
    "analysis" : {
        "analyzer" : {                
            "index_analyzer" : {                    
                "tokenizer" : "nGram",
                "filter" : ["lowercase"]
            },
            "search_analyzer" : {                                                    
                "tokenizer" : "nGram",
                "filter" : ["lowercase"]
            }
        },                               
        "// you'll need lucene dep for this: filter" : {                
            "snowball": {
                "type" : "snowball",
                "language" : "English"
            }
        }
    }
}

}

我已经插入了一个包含一个单词的文档,searching如果我搜索关键字 search它说什么也没找到...

它不会在索引之前停止,否则我错过了配置中的一些东西....

4

2 回答 2

5

您的查询看起来如何?

你的配置看起来不太好。尝试:

 ...
"index_analyzer" : {                    
   "tokenizer" : "nGram",
   "filter" : ["lowercase", "snowball"]
},
 "search_analyzer" : {                                                    
    "tokenizer" : "nGram",
    "filter" : ["lowercase", "snowball"]
}
},
"filter" : {
                "snowball": {
                    "type" : "snowball",
                    "language" : "English"
                }
            }
于 2011-02-14T18:45:55.893 回答
1

我在覆盖“default_search”和“default_index”分析器时也遇到了麻烦。

这虽然有效。如果需要,您可以将“index_analyzer”添加到默认类型中具有未指定分析器的所有字符串字段。

curl -XDELETE localhost:9200/twitter

curl -XPOST localhost:9200/twitter -d '
{"index": 
  { "number_of_shards": 1,
    "analysis": {
       "filter": {
                "snowball": {
                    "type" : "snowball",
                    "language" : "English"
                }
                 },
       "analyzer": { "a2" : {
                    "type":"custom",
                    "tokenizer": "standard",
                    "filter": ["lowercase", "snowball"]
                    }
                  }
     }
  }
}
}'

curl -XPUT localhost:9200/twitter/tweet/_mapping -d '{
    "tweet" : {
        "date_formats" : ["yyyy-MM-dd", "dd-MM-yyyy"],
        "properties" : {
            "user": {"type":"string"},
            "message" : {"type" : "string", "analyzer":"a2"}
        }
    }}'

curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{ "user": "kimchy", "post_date": "2009-11-15T13:12:00", "message": "Trying out searching teaching, so far so good?" }'

curl -XGET localhost:9200/twitter/tweet/_search?q=message:search 

curl -XGET localhost:9200/twitter/tweet/_search?q=message:try 
于 2011-03-15T13:39:51.260 回答