How to do , 'not contains' search for text and other fields in azure cognitive search

Soorya Prabha Jagatheesan 1 Reputation point
2022-12-01T07:14:41.427+00:00

1) What is the correct syntax for doing a not contains text search?

I would like to pull all fileNames that doesnot contain "test" in the file name.

2) For the same field i want to a contains search also like , I would like to pull all fileNames that contain "test" in the file name.

for the above 2 questions i want syntax like how to use it to search

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.
1,100 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 16,676 Reputation points Microsoft Employee
    2022-12-08T06:31:50.333+00:00

    @Soorya Prabha Jagatheesan I like to use Lucene query language as it's rather popular in the search tools so I will provide some examples using it.

    Not would be done via - or ! in your Lucene setup. Please see here for more information on NOT, OR, AND operators.

    For finding files that contain a "term" rather than the exact word, you can try a regex query like /.term./ /.part2./

    https://[service name].search.windows.net/indexes/[search index]/docs?api-version=2016-09-01&queryType=full&search=/.*term.*/ /.*part2.*/  
    

    Note: Azure Cognitive Search supports simple and full queries. Please use the full query to use Lucene.

    Please let us know if you have further questions or concerns.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.