Skip to Content
author's profile photo
Former Member

Custom property search

Hello all,

i found the following in a doc here on SDN.

<quote>

Building queries for certain custom properties is also possible with this factory class. This sample builds a query for the modelled custom property “fruits” in the namespace “custom” (see PropertyMetadataService) linked by a logical OR operation:

SearchQueryListBuilder sqb = new SearchQueryListBuilder();

sqb.setSelectedCustomProps(

"custom:fruits(value=banana),custom:fruits(value=pine)"

);

IQueryEntryList qel = sqb.buildSearchQueryList();

</quote>

I've used this code on a custom search component to search for resources with a given custom param and it works as described. Although I'm using a SearchQueryBuilder object, not a SearchQueryListBuilder object as used above.

Does anyone know what I need to do to change the search from a logical OR to a logical AND? Can I mix these, like (x AND y) OR z?

Thanks in advance,

Patrick.

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Best Answer
    Posted on Feb 28, 2005 at 03:29 PM

    Hi Patrick,

    > Although I'm using a SearchQueryBuilder object

    And this has a <i>buildSearchQueryList()</i> method?! (Mine does not.)

    Anyhow, what you are doing at the base is building an IQueryEntryList, consisting of IQueryEntries. To have to queries (for example a textual search term and a property query) bound together just set an operator query in the middle (this will be done automatically by the method you described, I expect).

    So create an IQueryEntry, set it's RowType to OPERATOR, set it's value to "AND" or "OR" or "NOT" and add this queryEntry to the queryEntryList in question.

    For a queryEntryList produced automatically, check the single queries (and modificate them, if wanted).

    Hope it helps

    Detlev

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Detlev Beutner

      Very helpful as usual Detlev.

      I think I'll talk to someone about the upgrade to SP10 before I write the code around SP9 though, probably better that way.

      Thanks again,

      Patrick.