11

I'm using the Core Service client in Tridion 2011SP to do a search for components with a certain schema.

I managed to filter out all components that have a certain value in a single line value field. Now I'm trying to filter out all components that have a date field set to a date before a given timestamp.

Does anyone know if this is even possible with the CM search? Because it's based on Solr, I thought I could do it with something like this:

searchQuery.BasedOnSchemas = new[] {
    new BasedOnSchemaData {
        Field = "PublicEmbargo",
        FieldValue = "[* TO 2013-8-20T09:55:00.000Z]",
        Schema = new LinkToSchemaData {
            IdRef = "tcm:10-123456-8",
            Title = "SomeSchemaWithDate"
        }
    }
};

However this doesn't seem to work and returns an error "maxClauseCount is set to 10240" from Solr.

1 Answer 1

12

I have never had to do this, but I think that this can be done through the API. The fact that you are getting this error is a good sign!

In Lucene (which Solr is based on) the maxClauseCount exceeded error is normally because the number of terms/unknowns in your query makes it very 'vague'. I believe that the value can be increased in configuration. However, the best approach is normally to simplify the query.

Can you try this with a less specific date query (fewer decimal places)? e.g. FieldValue = "[* TO 2013-08-20]" or FieldValue = "[1977-01-01 TO 2013-08-20]"

There is a little more information on this error in Lucene here.

Edit by Alvin: Using the same format ("[2011-01-01 TO 2012-01-01]") or even "[2012 TO 2015]" seems to work in advanced search as well. In the screenshot below, Components with a date field after 2012 are correctly filtered out (the Modified column is a separate date).

Advanced Search on a date uses the same format

7
  • Interesting that you choose 1977 to start the query with, probably even safe enough to use January 1, 2000 as there won't be much customers with content before that date. Mar 25, 2013 at 16:28
  • 1
    Sweet! This seems to work. Both from the Core Service as well as from a Virtual Folder query.
    – Kah Tang
    Mar 25, 2013 at 16:29
  • @Bart - I'm just showing my age! :) Mar 25, 2013 at 16:30
  • 1
    I tested and added a CME advanced search example. I'd just be careful with the syntax because search seemed to accept impractical dates with typos (e.g. 20155 works but will pull back too much and 2015d-01-01 works but I'm not sure what it means). Mar 12, 2015 at 18:36
  • 1
    Note I wasn't able to get * as a wild card to return the right range of items in advanced search. Starting with the asterisk as in [* TO 2012-01-01] returned all items, even with dates after 2012-01-01. Mar 12, 2015 at 20:31

Your Answer

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

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