0

I have a data collection like { type: "customer", customer: { name: "Adam", mobile_number: "+919988776655" } } , and i am trying to use this query like reference from previously asked question here: MongoDB full text search, autocomplete on two fields I updated my query to this:

const searchStep = {
    $search: {
        // Read more about compound here:
        // https://docs.atlas.mongodb.com/reference/atlas-search/compound/
        compound: {
            should: [
                {
                    autocomplete: {
                        "query": "9988776655",
                        path: "customer.mobile_number",
                    },
                },
                {
                    autocomplete: {
                        "query": "9988776655",
                        path: "customer.name",
                    },
                },
            ],
        },
    },
}

But it does not return any result. Any suggestion would be appreciated. Thanks

const searchStep = {
    $search: {
        // Read more about compound here:
        // https://docs.atlas.mongodb.com/reference/atlas-search/compound/
        compound: {
            should: [
                {
                    autocomplete: {
                        "query": "9988776655",
                        path: "customer.mobile_number",
                    },
                },
                {
                    autocomplete: {
                        "query": "9988776655",
                        path: "customer.name",
                    },
                },
            ],
        },
    },
}

This is what i tried, and i was expecting to get the result the object containing mobile_number "9988776655"

0 Answers0