Hello EveryOne,
I just started with elastic search. Its quite interesting and joy to learn.
However i have been stuck implementing the stopwords.
Here's my index:
url -XPUT 'http://localhost:9200/my_indice' -d'
{
"settings": {
"analysis": {
"char_filter": {
"&_to_and": {
"type": "mapping",
"mappings": [ "&=> and "]
}},
"filter": {
"my_stopwords": {
"type": "stop",
"stopwords": [ "the", "a" ,"from" ,"is"]
}},
"analyzer": {
"my_analyzer": {
"type": "custom",
"char_filter": [ "html_strip", "&_to_and" ],
"tokenizer": "whitespace",
"filter": [ "lowercase", "my_stopwords" ]
}}
}}}'
and here are my mappings:
curl -XPUT 'http://localhost:9200/my_indice/_mapping/test' -d '
{
"properties": {
"tags": {
"type": "string",
"analyzer": "my_analyzer"
},
"displayName": {
"type": "string"
}
}'
I have cross checked whether my custom analyzer is working , here's the result:
curl -XGET 'http://localhost:9200/my_indice/_analyze?analyzer=my_analyzer' -d '
The quick & brown is a fox'
"tokens": [{
"token": "quick",
"start_offset": 5,
"end_offset": 10,
"type": "word",
"position": 2
}, {
"token": "and",
"start_offset": 11,
"end_offset": 12,
"type": "word",
"position": 3
}, {
"token": "brown",
"start_offset": 13,
"end_offset": 18,
"type": "word",
"position": 4
}, {
"token": "fox",
"start_offset": 24,
"end_offset": 27,
"type": "word",
"position": 7
}]
}
So it clearly shows that custom analyzer is working.
But when i search for documents , it's retrieving documents containing "the".
Here's my query:
curl -XPUT 'http://localhost:9200/my_indice/test' -d '
'{
"query": {
"match": {
"allTags": "the"
}
}
}'
I want to know whether i skipped anything or is there any mistake either with my mappings or query.
thanks,
Ram.