Search for hashtags - Find exact matches only

Hi,

I am using analyzer and filters described at
http://www.fullscale.co/blog/2013/03/04/preserving_specific_characters_during_tokenizing_in_elasticsearch.html
to preserve # chars. See mapping blow:

curl -XPUT 'http://localhost:9200/twitter' -d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 1
},
"analysis" : {
"filter" : {
"tweet_filter" : {
"type" : "word_delimiter",
"type_table": ["# => ALPHA", "@ => ALPHA"]
}
},
"analyzer" : {
"tweet_analyzer" : {
"type" : "custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase", "tweet_filter"]
}
}
}
},
"mappings" : {
"tweet" : {
"properties" : {
"msg" : {
"type" : "string",
"analyzer" : "tweet_analyzer"
}
}
}
}
}'

But now when searching, e.g.
http://localhost:9200/_search?pretty=true&q="%23elasticsearch" I get hits
on ...#elasticsearch... but ALSO on elasticsearch without the #. How can i
only search for full hashtags using the query_string syntax? Thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/849ae584-c416-4f85-bba9-698367a1ccb1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

1 Like

Can someone help?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/aec204e6-ccf7-4f1b-bd22-0bd6e65e1547%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

You have enabled the tweet_analyzer only for field "msg" so you should
execute a field search, something like

curl '0:9200/_search?pretty&q=msg:%23elasticsearch'

Or you change the _all field analyzer also to tweet_analyzer (which is
probably not what you want), see
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-all-field.html

Jörg

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH-wJ2-FnjL4YtbE2AEr-9BWa2vYAadJey7gQvdVayQmA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.