cts:element-values can either return the full values based on the ordering of
those values (the full values) or on the frequency of the occurrences of those
values.
Since "A" and "AXYZ" aren't values of the element given to element-values, you
can't return things based on the ordering of those. It sounds like you want to
return values of one element based on the ordering of values of some other
element.
You could do something like:
cts:element-value-co-occurrences(xs:QName("TS"),xs:QName("Searchable-Value"),("limit=10","fragment-frequency","item-order","concurrent"))!fn:data(.//cts:value[2])
That orders things on the first element, and plucks out values of the second.
//Mary
On 07/16/2015 10:17 AM, Indrajeet Verma wrote:
Hi All,
I am using cts:element-values() to return suggestions based on the input
char/string and its other matches and I want the result in order of input. If I
entered A, the match of A should come first and then matches of others.
Please help me to correct my code!
Query-
---
let $query := cts:or-query(cts:element-range-query(xs:QName("sum:TS"), "=",
("A", "AB", "AC","ABDC","AXYZ"),
("collation=http://marklogic.com/collation/codepoint"), 1), ())
let $values :=
cts:element-values(xs:QName('Searchable-Value'),(),(fn:concat("limit=", 10)
,"fragment-frequency","item-order", "concurrent"), $query)
return $values
The cts:element-values() is not returning results in the order of inputs ("A",
"AB", "AC","ABDC","AXYZ").
Might be in this example the output same however when ("A", "AB",
"AC","ABDC","AXYZ", ....) increase then the order of results unexpected.
Is there any way to show the results in order of input ("A", "AB",
"AC","ABDC","AXYZ"....)?
XML document 1
<?xml version="1.0" encoding="UTF-8"?>
<Company>
<Company-Name>NOBLE CORP SWITZERLAND</Company-Name>
<Searchable-Value>{"CompanyName":"NOBLE CORP
SWITZERLAND","TS":"AC"}</Searchable-Value>
</Company>
XML document 2
<?xml version="1.0" encoding="UTF-8"?>
<Company>
<Company-Name>SAFEGUARD SCIENTIFICS INC</Company-Name>
<Searchable-Value>{"CompanyName":"SAFEGUARD SCIENTIFICS
INC","CIK":"86115","TS":"A"}</Searchable-Value>
</Company>
XML document 3
<?xml version="1.0" encoding="UTF-8"?>
<Company>
<Company-Name>CRUCELL NV</Company-Name>
<Searchable-Value>{"CompanyName":"CRUCELL
NV","CIK":"1126136","TS":"AB"}</Searchable-Value>
</Company>
.........
............
Expected output:
------------
<Searchable-Value>{"CompanyName":"SAFEGUARD SCIENTIFICS
INC","CIK":"86115","TS":"A"}</Searchable-Value>
<Searchable-Value>{"CompanyName":"CRUCELL
NV","CIK":"1126136","TS":"AB"}</Searchable-Value>
<Searchable-Value>{"CompanyName":"NOBLE CORP
SWITZERLAND","TS":"AC"}</Searchable-Value>
Regards,
Indy
_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general