0

On our SharePoint 2019 Server we have a KQL that searches the whole Tenant for specific documents, by querying Managed Properties, like so: ContentType:MyContentType AND FileType:pdf.

According to https://docs.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference#using-multiple-property-restrictions-within-a-kql-query the following 2 queries are identical:

  • author:"John Smith" filetype:docx
  • author:"John Smith" AND filetype:docx

However, I've noticed that my KQL didn't return all the data (only 3 documents instead of ~180):

  • ContentType:MyContentType AND FileType:pdf - returned 3 documents
  • ContentType:MyContentType FileType:pdf - returned ~180 documents
  • ContentType:MyContentType +FileType:pdf - returned ~180 documents
  • (ContentType:MyContentType + FileType:pdf) - doesn't work notice the space after +

With the three queries above I found, that the KQL including AND doesn't work properly. It doesn't return all the elements. It almost seems as if it was looking for the term and in the documents, implicitly building a query like ContentType:MyContentType "AND" FileType:pdf (ContentType:MyContentType, content=AND, FileType:pdf).

Does anyone know why the query doesn't work when using the AND boolean operator?

5
  • Are you using quotation marks with MyContentType e.g. ContentType:"MyContentType" AND FileType:pdf ? Aug 25, 2022 at 13:21
  • Yes, but it doesn't change anything. For me ContentType:"MyContentType" AND FileType:"pdf" is the same as ContentType:MyContentType AND FileType:pdf
    – Johannes
    Aug 26, 2022 at 7:20
  • the quotations around filetype don't appear to be needed Aug 26, 2022 at 9:28
  • Why you want to use "AND" work in your KQL because by default if you don't provide anything between two filter conditions, it will be considered AND condition only. You only need to provide logical operator when you specially want to you OR or NOT. Aug 26, 2022 at 12:34
  • I know that "AND" is the default. But shouldn't it still work if I specify the default?
    – Johannes
    Aug 29, 2022 at 6:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.