'phrase' searches don't work for autocomplete fields?

I wasn’t able to get a result when I use a $search query like this:

  phrase: {
    path: 'tags',
    query: 'Some Words'
  }
}

Where tags is defined in the index with these settings:

tags: {
   "type": "autocomplete",
    "tokenization": "edgeGram",
    "minGrams": 3,
    "maxGrams": 7,
    "foldDiacritics": false,
}

Modifying the index to…

tags: { type: "string" }

…fixed this for me. Are phrase and autocomplete incompatible? I didn’t see anything about this in the docs and spent the past half a day narrowing it down. Any plans to add support for this?

Ideally I’d like to use phrase in a compound.must for anything the user passes along in quotes and return exact matches for that. Is there a way to use autocomplete but NOT use phrase, and instead perhaps use sequential: tokenOrder and, say, maxEdits: 0?

Then I’d have any other words NOT in quotes split into an array and used as the query in a compound.should expression.

Thank you so much for this amazing software!

Ignore the maxEdits: 0 bit since that’d be in fuzzy which would need to be omitted for an exact match expression anyway.

OK, my issue was that I had to find an undocumented feature of index field definitions, which is that a field can be defined as an array of types!

someField: [     /* <--- NOT DOCUMENTED -- found in video
  { type: "string" },
  { type: "autocomplete", /*...*/ },
]

I found the answer in Atlas Search from Soup to Nuts: The Restaurant Finder Demo App.

Now most or all the issues I was hitting have gone away.

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