How to filter any field that contains a # or does not end with .htm

Thomas 21 Reputation points
2021-03-10T13:59:40.06+00:00

Hi all,

I have an URL field in my index but would filter out any entries where the field either contains a '#' or does not end with '.htm'.

Not sure how the $filter query string needs to be.

https://xxx.search.windows.net/indexes/xxx/docs?api-version=2020-06-30-Preview&$filter=???&search=*

Any suggestions?

Thomas

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
834 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 15,786 Reputation points Microsoft Employee
    2021-03-11T05:24:41.037+00:00

    @Thomas Thank you for your question.

    The first item is that you will need to convert the # in your URL field to %23 as # is considered an unsafe character. More information on encoding unsafe URL characters can be found here.

    Since it sounds like you'll want this to be applied to every query, regardless of the full-text search terms, I'd suggest using something like an OData filter and using an operator such as not to have it not include %23 or .htm. More information on OData filters can be found here.

    Please review this content and let us know if there are any further questions on the matter.