Ah, the synonym file was in the config directory of only the master, but
not in the rest of the data nodes. That solved it, thanks!
As a follow up question related more to the original prompt title, why
isn't the synonym filter applied to the supplied query? The analyzer for
synonyms only seem to be applied during index time, but when I apply the
analyzer to the query, it doesn't seem to work.
index settings as in previous post
synonyms.txt: pain head, head pain, head hurt, head throb, throb head =>headach
curl -XPUT http://localhost:9200/test/items/_mapping -d
'{
"items": {
"properties": {
"name": {
"type": "string",
"analyzer": "name_analyzer"
}
}
}
}'
{"ok":true,"acknowledged":true}
Indexing some documents:
curl -XPUT http://localhost:9200/test/items/1 -d '{ "name": "headache" }'
{"ok":true,"_index":"test2","_type":"items","_id":"1","_version":1}
curl -XPUT http://localhost:9200/test/items/2 -d '{ "name": "back pain" }'
{"ok":true,"_index":"test2","_type":"items","_id":"2","_version":1}
curl -XPUT http://localhost:9200/test/items/3 -d '{ "name": "head hurts" }'
{"ok":true,"_index":"test2","_type":"items","_id":"3","_version":1}
The analyzer looks fine:
curl -XGET http://localhost:9200/test/_analyze?analyzer=name_analyzer -d
"head hurts"
{"tokens":[{"token":"headach","start_offset":0,"end_offset":10,"type":
"SYNONYM","position":1}]}
A normal query for a synonym term works as expected since the documents
have the synonym filter applied during index time:
curl -XGET http://localhost:9200/test/items/_search -d
'{
"query": {
"query_string": {
"query":"headaches",
"analyzer":"name_analyzer",
"default_field":"name"
}
}
}'
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},
"hits":{"total":2,"max_score":0.30685282,"hits":[{"_index":"test2","_type":
"items","_id":"1","_score":0.30685282, "_source" : { "name": "headache" }},{
"_index":"test2","_type":"items","_id":"3","_score":0.30685282, "_source" :
{ "name": "head hurts" }}]}}
But then this query doesn't work as expected. Why wouldn't it map the query
"head hurts" to the synonym "headach"?
/*******************************************
- query time synonym filter doesn't work? *
*******************************************/
curl -XGET http://localhost:9200/test/items/_search -d
'{
"query": {
"query_string": {
"query":"head hurts",
"analyzer":"name_analyzer",
"default_field":"name"
}
}
}'
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},
"hits":{"total":0,"max_score":null,"hits":}}
Thanks!
Irving
On Wednesday, November 14, 2012 11:52:21 AM UTC-8, Igor Motov wrote:
The synonym path is getting resolved as absolute path first and then
against config directory. So, in your case the synonyms.txt file should be
in 'config' directory all data nodes. When it fails do you see any error
messages in log files on other nodes?
On Wednesday, November 14, 2012 12:14:51 PM UTC-5, Ivan Brusic wrote:
Where is the synonyms.txt in the filesystem? It should be relative to the
config directory (es.path.conf).
--
Ivan
On Thu, Nov 8, 2012 at 12:46 PM, Irving irv...@step4md.com wrote:
Hi everyone,
I'm trying to get synonyms to work, but for some reason I'm unable to
create the index with synonym settings (acknowledge=False) and end up with
a cluster health state of red. The log file also doesn't show any errors.
[2012-11-08 20:33:01,265][INFO ][cluster.metadata ] [Lora
Danish] [test] creating index, cause [api], shards [5]/[1], mappings
[2012-11-08 20:33:01,462][DEBUG][gateway.s3 ] [Lora
Danish] writing to gateway
org.elasticsearch.gateway.shared.SharedStorageGateway$2@aeb7058 ...
[2012-11-08 20:33:01,604][DEBUG][gateway.s3 ] [Lora
Danish] wrote to gateway
org.elasticsearch.gateway.shared.SharedStorageGateway$2@aeb7058, took 142ms
Index settings on ec2 cluster (3 nodes in cluster):
curl -XPUT 'http://[ec2]:9200/test/' -d
'{
"settings": {
"index": {
"analysis": {
"analyzer": {
"name_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "stop", "snowball",
"asciifolding", "synonym"]
}
},
"filter": {
"synonym": {
"type": "synonym",
"synonyms_path": "synonyms.txt",
"ignore_case": "true"
}
}
}
}
}
}'
{"ok":true,"acknowledged":false}
But if I take away the synonyms, I get acknowledged=True:
curl -XPUT 'http://[ec2]:9200/test/' -d
'{
"settings": {
"index": {
"analysis": {
"analyzer": {
"name_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "stop", "snowball",
"asciifolding"]
}
}
}
}
}
}'
{"ok":true,"acknowledged":true}
Also, however, if I run it locally, I get acknowledged=True as well:
curl -XPUT 'http://[ec2]:9200/test/' -d
'{
"settings": {
"index": {
"analysis": {
"analyzer": {
"name_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "stop", "snowball",
"asciifolding", "synonym"]
}
},
"filter": {
"synonym": {
"type": "synonym",
"synonyms_path": "synonyms.txt",
"ignore_case": "true"
}
}
}
}
}
}'
{"ok":true,"acknowledged":true}
synonyms.txt on the ec2 master and on local
pain head, head pain, head hurt, head throb, throb head => headache
Any thoughts? Thanks!
Irving
--
--