Filter terms tags with hyphen and whitespace


(bashir-2) #1

I am trying to filter search results based on tags using terms filter.
my tags field is not_analyzed but I think the query filter processor
breaks down terms by spaces and hyphens but I want to match tags like
"wi-fi" and not tags "wi" and "fi".how do I accomplish this?


(David Pilato) #2

You have to modify the mapping for this field and use a keyword analyzer or no analyzer at all.

HTH
David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 9 juin 2012 à 20:41, Bashir bashir@coderwall.com a écrit :

I am trying to filter search results based on tags using terms filter.
my tags field is not_analyzed but I think the query filter processor
breaks down terms by spaces and hyphens but I want to match tags like
"wi-fi" and not tags "wi" and "fi".how do I accomplish this?


(Clinton Gormley) #3

On Sat, 2012-06-09 at 23:12 +0200, David Pilato wrote:

You have to modify the mapping for this field and use a keyword analyzer or no analyzer at all.

Or synonyms, or the word-delimiter token filter. It very much depends
on what your data looks like and what you're trying to achieve.

clint


(bashir-2) #4

so I have the field as not_analyzed but term search with dashes still don't
work. Here is what I have:
mapping :show => { :properties => {
:user => { :type => 'multi_field',
:index => 'not_analyzed', :fields => {
:username => {:type =>
'string', :index => 'not_analyzed'}}}}}

tire.search do
filter :term, 'user.username' => username
end

however if I have a user with username "mary-lynn" and another one with
"mary" the following happens:
search("mary-lynn") # 0 results
search("mary") # 2 results

I'm not understanding where things get tokenized. I assume "not_analyzed"
fields are not tokenized at all.
does the term filter tokenize argument?
I really hope to understand the elasticsearch mechanism here. any input is
appreciated.
thanks,
bashir

On Saturday, June 9, 2012 2:12:02 PM UTC-7, David Pilato wrote:

You have to modify the mapping for this field and use a keyword analyzer
or no analyzer at all.

HTH
David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 9 juin 2012 à 20:41, Bashir bashir@coderwall.com a écrit :

I am trying to filter search results based on tags using terms filter.
my tags field is not_analyzed but I think the query filter processor
breaks down terms by spaces and hyphens but I want to match tags like
"wi-fi" and not tags "wi" and "fi".how do I accomplish this?

On Saturday, June 9, 2012 2:12:02 PM UTC-7, David Pilato wrote:

You have to modify the mapping for this field and use a keyword analyzer
or no analyzer at all.

HTH
David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 9 juin 2012 à 20:41, Bashir bashir@coderwall.com a écrit :

I am trying to filter search results based on tags using terms filter.
my tags field is not_analyzed but I think the query filter processor
breaks down terms by spaces and hyphens but I want to match tags like
"wi-fi" and not tags "wi" and "fi".how do I accomplish this?

On Saturday, June 9, 2012 2:12:02 PM UTC-7, David Pilato wrote:

You have to modify the mapping for this field and use a keyword analyzer
or no analyzer at all.

HTH
David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 9 juin 2012 à 20:41, Bashir bashir@coderwall.com a écrit :

I am trying to filter search results based on tags using terms filter.
my tags field is not_analyzed but I think the query filter processor
breaks down terms by spaces and hyphens but I want to match tags like
"wi-fi" and not tags "wi" and "fi".how do I accomplish this?


(system) #5