How can i search text but ignore some word pattern?

text : this(_[_shark_]_)thetext,and thissharkan animal // string

i want to search shark but ignore the pattern (_[_${someWord}_]_)

so the result that i expect must be found, because the shark word found at 32nd letter.

but if the text is this(_[shark_]_)thetext,and thisan animal , it must not found because i want to ignore the pattern

this is my example query:

    $search: {
      index: "text",
      regex: {
        query: "<someQuery>",
        allowAnalyzedField: true,
        path: "text"

If that pattern of text is always to be ignored in searches, then it can be ignored during indexing, using the regex token filter. Given that you’re looking for substrings within words, your custom analyzer using the regex token filter would need to start with the keyword tokenizer.


thank you very much sir, i can do it because of your answer. :tada::tada:

1 Like

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