Unable to search data containing math expression

Hi ES folks,

Hope everyone is doing fine. I am facing a problem when querying data containing mathematical expressions. For example I have following data indexed in my ES

  • what is 3+4
  • what is 3-4
  • what is 3*4
  • what is 3/4

when I try to search for what is 3+4 the first response comes out to be what is 3*4 the actual result is 3-4 in the response list.

I am using an Arabic analyzer for indexing and searching. I have googled and tried a couple of analyzers but no luck. any help would be appreciated.

{
    “total”: 5,
    “max_score”: 0.12465363,
    “took”: 2,
    “results”: [
        {
            “sort”: [
                “arabic”,
                0.12465363
            ],
            “_type”: “faqs”,
            “_id”: “63f5fc52fe32c80fc9ef6fcb”,
            “score”: 0.12465363,
            “_score”: 0.12465363,
            “_index”: “faqs_index”,
            “data”: {
                “answer”: [
                    {
                        “content”: “3*4 is 12",
                    }
                ],
                “category”: “arabic”,
                “question”: “what is 3*4"
            }
        },
        {
            “sort”: [
                “arabic”,
                0.12465363
            ],
            “_type”: “faqs”,
            “_id”: “63f5fc67fe32c80fc9ef6fcd”,
            “score”: 0.12465363,
            “_score”: 0.12465363,
            “_index”: “faqs_index”,
            “data”: {
                “answer”: [
                    {
                        “content”: “3-4 is -1"
                    }
                ],
                “category”: “arabic”,
                “question”: “what is 3-4"
            }
        },
        {
            “sort”: [
                “arabic”,
                0.12465363
            ],
            “_type”: “faqs”,
            “_id”: “63f5fc5efe32c80fc9ef6fcc”,
            “score”: 0.12465363,
            “_score”: 0.12465363,
            “_index”: “faqs_index”,
            “data”: {
                “answer”: [
                    {
                        “content”: “3+4 is 7"
                    }
                ],
                “category”: “arabic”,
                “question”: “what is 3+4"
            }
        },
        {
            “sort”: [
                “arabic”,
                0.12465363
            ],
            “_type”: “faqs”,
            “_id”: “63f5fc80fe32c80fc9ef6fce”,
            “score”: 0.12465363,
            “_score”: 0.12465363,
            “_index”: “faqs_index”,
            “data”: {
                “answer”: [
                    {
                        “content”: “3/4 is 0.75"
                    }
                ],
                “category”: “arabic”,
                “question”: “what is 3/4"
            }
        },
        {
            “sort”: [
                “arabic”,
                0.05758412
            ],
            “_type”: “faqs”,
            “_id”: “63f606b5fe32c8132b3b580a”,
            “score”: 0.05758412,
            “_score”: 0.05758412,
            “_index”: “faqs_index”,
            “data”: {
                “answer”: [
                    {
                        “content”: “3/4 is 0.75"
                    }
                ],
                “category”: “arabic”,
                “question”: “what is 3/4"
            }
        }
    ]
}

Hi @Hassan_zaib_Hayat

Do you use arabic analyzer for english text?
I would try some tests with the whitespace analyzer.
It will not remove the operators, "+ - *", like other analyzers.

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