Solr convert having problems with pattern_replace filter

Hi - I'm trying to convert to using ES having done SOLR for a long time so please bear with me. When I try and put the following I get error message...

"Custom Analyzer [text_suggest_analyzer] failed to find filter under name [punctuationfilter]"

Why? I can't see much wrong with my json (but then I don't yet have a trained eye).

Thnks.

curl -H'Content-Type: application/json' -X PUT http://localhost:9200/my_hw_index -d  '
{
  "settings" : {
    "analysis" : {
      "analyzer" : {
        "text_suggest_analyzer" : {
          "type" : "custom",
          "tokenizer" : "basic_tokenizer",
          "filter" : [
            "lowercase",
            "punctuationfilter"
          ]
        }
      },
      "char_filter" : {
        "punctuationfilter" : {
          "type" : "pattern_replace",
          "pattern" : "\\p{Punct}",
          "replacement" : " "
        }
      },
      "tokenizer" : {
        "basic_tokenizer" : {
          "type" : "standard"
        }
      }
    }
  }
}'

Oh look - I managed to answer my own question. It seems that my custom pattern_replace filter needs to be reference in my custom analyzer in a "char_filter" section not in a "filter" section. So the following is correct...

curl -H'Content-Type: application/json' -X PUT http://localhost:9200/autocompleter -d  '
{
  "settings" : {
    "analysis" : {
      "analyzer" : {
        "text_suggest_analyzer" : {
          "type" : "custom",
          "tokenizer" : "basic_tokenizer",
          "filter" : [
            "lowercase"
          ],
          "char_filter" : ["punctuationfilter"]
        }
      },
      "char_filter" : {
        "punctuationfilter" : {
          "type" : "pattern_replace",
          "pattern" : "\\p{Punct}",
          "replacement" : " "
        }
      },
      "tokenizer" : {
        "basic_tokenizer" : {
          "type" : "standard"
        }
      }
    }
  }
}'
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.