According to the Search Developers Guide:
Each constraint is named, and the name must be unique across all operators and constraints in your options node.
We are using a content enrichment package that produces output like this:
`<TM360:Measurements Measurements="Distance">
<Measurements:Distance Amount="3" Unit="inches"/>
</TM360:Measurements>
<TM360:Measurements Measurements="Volume">
<Measurements:Volume Amount="5.0" Unit="liters"/>
</TM360:Measurements>`
Looking at “Amount”:
The attribute localName is not unique, but the element that contains it is unique.
Is there a way get around the constraint name uniqueness limitation to build a constrained search, say, “Amount: 5.0” that would include the indexes over both entries above?
What is the best way to handle this situation?
You could create a custom constraint to achieve this. I succeeded in doing this using the following three scripts:
Here’s the setup script, which creates the two “Amount” range indexes and adds a couple of sample documents (test1.xml and test2.xml):
Below is search.xqy, which makes two searches:
search:search("Amount:3",$options)search:search("Amount:5",$options)Note in particular the $options node, which defines the custom constraint:
And finally, here’s the custom-constraint.xqy code, which is what translates the constraint text into a cts OR query across the two Amount indexes:
If you want your constraint to function as a facet also, then you’d additionally need to implement the start-facet and finish-facet functions (and augment the definition in your options node accordingly. The Search Developer’s Guide includes an example of how to do this.