Use Database Search with the Keyword IN to Shorten Your Query

Jul 28, 2008

Sometimes we encounter the need to perform a search in content server that requires a lot of work with the query operator. Between that and a few other variables it might be possible to craft a query that is too long for content server. This happens especially with generated queries. If you are using universal query syntax or a verity engine for your search engine you might also encounter this. If the data you are searching on is metadata based you might be better off temporarily switching over to a database based search on the fly to find your results. By adding this setting to the query string you can change how content server interprets your search:


In most installations the Search Query Format setting will default to UNIVESAL. Now that you have switched over to a database based search you can set your query string using the IN operator for a much shorter query converting from something like this:

QueryText="xType <MATCHES> `A` <OR> xType <MATCHES> `B` <OR> xType <MATCHES> `C`"


QueryText="xType IN ('A', 'B', 'C')"

If you’re on a Database Full Text setup to start with you can still do this type of thing AND use full text like this:

QueryText="( xType IN ('A', 'B', 'C', 'D')) and (<ftx>keyword</ftx>)"

Perhaps the best thing you can do is at least take a moment to evaluate why you must have so much ‘or’ based logic in your query in the first place. Or is almost always one of the most costly instructions.

© 2019 Jason Stortz