Indexing annotation as they are {@this.Example}

Hello, I'm trying to figure out a way to index a special type of annotations that I developed so I then I can look by them later at query time, for example I may have a couple of documents with text

"this is a cool {@this.Example}"
"I think this is super cool"

I want to search for "I want something cool {@this.Example}" and match only the first document, however right now I'm matching both since there's an overlap of terms, I was trying to subquery my way around this, but seems like my annotations get indexed in a different way that I cannot match

{
        'query': {
            "bool":{
                "must":{
                    "match": { 
                        "doc_field":"{@this.Example}"
                    }
                },
                "should":{
                    "doc_field":{
                            "query":"I want something cool",
                            "fuzziness":"1"
                        }
                }
            }
        }
    }

I'm using the following Analyzer but without much results

"annotated_analyzer": {
                    "type": "custom",
                    "filter": [
                        "lowercase"
                    ],
                    "tokenizer": "whitespace"
                }

oddly enough when creating the mapping for a field the search_analyzer is ignored, I'm not even sure if this analyzer is being used at search time

Any ideas on how I can achieve this behavior? I'm sure I must use an analyzer for this task to make sure elastic indexes the annotation as is

You could try to pass your fields through the analyze API to see how they are analyzed, and your query through the _validate/query API to see how it is parsed. If it still does not make sense to you why it does not match, please share the output of these two APIs so that I can have a look.

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