Hi, Jaydip:

To expand on Rob's good suggestion ...

The index always matches a document fragment.

A searchable expression like //SUGGESTION doesn't change that.

The unfiltered search against the index matches document fragments that have 
both a SUGGESTION element and a value of "wireless keyboard" in the path range 
index.

For the matched documents, the searchable expression also extracts the 
SUGGESTION nodes.

Because the search is unfiltered, my understanding is that the extracted nodes 
would not be checked for false positives. The predicate would just take the 
subset of the extracted nodes for the matched documents.

Back to Rob's point -- the standard guidance is to model each document as a 
row, not a table.  That should solve the problem because any SUGGESTION 
document that matches will be a true positive.

By the way, it's a better practice to use fn.subsequence(cts.search(...), 1, 2) 
instead of a [1 to 2] predicate.  fn.subsequence() iterates lazily.  A 
predicate is applied to all results (except where optimized away).


Hoping that helps,


Erik Hennum


________________________________
From: [email protected] 
[[email protected]] on behalf of Rob Szkutak 
[[email protected]]
Sent: Friday, May 06, 2016 7:12 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Not able to use indexes in cts:search

Hello,

It seems to me the simplest and best approach here would be to have one 
suggestion per document rather than multiple suggestions in each document.

Best,
Rob

Rob Szkutak
Senior Consultant
MarkLogic Corporation
[email protected]
www.marklogic.com<http://www.marklogic.com>

________________________________
From: [email protected] 
[[email protected]] on behalf of Jaydip Rananavare 
[[email protected]]
Sent: Friday, May 06, 2016 8:30 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Not able to use indexes in cts:search

Hi All,

We have following document

<SUGGESTIONS>
<SUGGESTION>
<PREF-LABEL>computer</PREF-LABEL>
<ALT-LABEL>laptop</ALT-LABEL>
<HIDDEN-LABEL>super computer</HIDDEN-LABEL>
</SUGGESTION>
<SUGGESTION>
<PREF-LABEL>keyboard</PREF-LABEL>
<ALT-LABEL>virtual keyboard</ALT-LABEL>
<HIDDEN-LABEL>wireless keyboard</HIDDEN-LABEL>
</SUGGESTION>
</SUGGESTIONS>

when user searches for any ALT-LABELS or HIDDEN-LABELS we want to show 
PREF-LABEL as suggestion for that we have used following query

cts:search(//SUGGESTION, cts:path-range-query( 
"/SUGGESTIONS/SUGGESTION/HIDDEN-LABEL", "=" , ("wireless keyboard"), 
("collation=http://marklogic.com/collation/en/S1";)), ("unfiltered"))[1 to 2]

When we pass "filtered" option to cts:search, it works properly with a little 
performance hit, but when we pass "unfiltered" option it does not give correct 
result rather it fetches only first result,
We have also added path range index for above path.(also tried with 
element-value-query)

Any help would be appreciated :)

--

Thanks and regards,

Jaydip Rananavare

M +91 98 60 07 39 90
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to