Word delimiter filter - ignore words with hyphen


(Patrick Norwood) #1

Hi all,

I would really appreciate if anyone could navigate me, how I should set my
word_delimiter_filter to skip words containing hyphen? The desired result
is that the word with '-' in them, will be ignored by word delimiter filter.
One possible way that I tried to implement was using protected_words option
with regular expression - but I am not sure whether this is possible.
My settings for word_delimiter_filter are as follows:
:word_delimiter_filter => {
"type" => 'word_delimiter',
"preserve_original" => true,
"generate_number_parts" => false,
"split_on_case_change" => false,
"split_on_numerics" => false,
}

I tried adding this: "protected_words" => [/.-./] ...but it did not
work.

Is there any way to achieve this? Thanks in advance.

--
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/be0e2372-491f-423a-8a05-d1a2400e622f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #2

Patrick,

If I understand correctly, you just want to preserve the dashes as is and
not "word-delimit" on them. You can try something like this (I am just
preserving the - symbol: \u002D):

  "analysis": {
    "analyzer": {
      "wd1": {
        "tokenizer": "whitespace",
        "filter": [
          "wd1"
        ]
      }
    },
    "filter": {
      "wd1": {
        "type": "word_delimiter",
        "type_table": [
          "\\u002D => ALPHANUM"
        ]
      }
    }
  }

--
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/8bb175ed-eb4e-4824-9d54-82439383779b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3