Text Search on Multiple Fields and Sub String

Hi Everyone,

I want to perform a search operation in my collection & have stored the fields for which I need to perform a search. I have implemented compound search as I would need location also.

Now, there are multiple problems

  1. Problem 1: I can’t search for a substring, I need to change the configuration to autocomplete but then I can’t apply to autocomplete on multiple fields. Also, not sure how to use or operation with multiple autocomplete fields, (Not sure if that could impact performance)

  2. Problem 2: If I search via text only then I can’t search substring.

Query:

Tasks.rawCollection()
.aggregate([
  {
    $search: {
      compound: {
        must: {
            text: {
              query: obj.query,
              path: {
                "wildcard": "*"
              }
          }
        },
        should: {
          near: {
            origin: {
              type: "Point",
              coordinates: [28.799046, 76.1],
            },
            pivot: 1000,
            path: "address.point",
          },
        },
      },
    },
  },

  {
    $addFields: {
      score: {
        $meta: "searchScore",
      },
    },
  },
  {
    $sort: {
      score: -1,
      _id: -1,
    },
  },
  {
    $limit: 5,
  },
  {
    $project: {
      task_id: 1,
      title: 1,
      description: 1,
      score: 1,
    },
  },
])
.toArray()

Please help