For SharePoint search, I create a KQL query that, among other things, sometimes checks whether an entity has one of several interesting substrings appearing in one particular property.

The property itself is a comma-separated list of integral IDs, and every atom of my body dislikes this solution, but apparently it works and at this point in time, it's what I'm working with.

So, we have the property ReallyLongAndCumbersomeName that can look something like 245, 2451, 21, 96612, 5215.

And so a query can contain this:

(ReallyLongAndCumbersomeName:29 OR ReallyLongAndCumbersomeName:30 OR ReallyLongAndCumbersomeName:31 OR ReallyLongAndCumbersomeName:32 OR ReallyLongAndCumbersomeName:33 OR ReallyLongAndCumbersomeName:34 OR ReallyLongAndCumbersomeName:20 OR ReallyLongAndCumbersomeName:35 OR ReallyLongAndCumbersomeName:36 OR ReallyLongAndCumbersomeName:21 OR ReallyLongAndCumbersomeName:427382 )

So the question is, can I simplify this to something like

ReallyLongAndCumbersomeName:(29 OR 30 OR 21 OR 32 OR 33 OR 34 OR 20 OR 35 OR 36 OR 21 OR 427382)?


You can use the query text as :

ReallyLongAndCumbersomeName:29 OR 30 OR 21 OR 32 OR 33 OR 34 OR 20 OR 35 OR 36 OR 21 OR 427382

I use the query text get the relevant results:

enter image description here

| improve this answer | |
  • Thank you, that does indeed work syntactially! However, I get more results this way. Any idea of why? My original query gets 120,537 rows (total, and including duplicates), this other form gets 1,047,946 total and 1,257,535 with duplicates. – Christofer Ohlsson Jan 2 '19 at 9:35
  • An entry with this value 6,41,85976,96052,244787,244791,244792,244793 gets returned by ReallyLongAndCumbersomeName:30 OR 427382 but not by (ReallyLongAndCumbersomeName:30 OR ReallyLongAndCumbersomeName:427382). I don't understand why. – Christofer Ohlsson Jan 2 '19 at 9:47
  • I have OtherProperty with the value 0427382 on this very entity, so I guess that should be why it gets returned. And so I don't think this works like I was hoping? – Christofer Ohlsson Jan 2 '19 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.