2013-07-24 8 views
5

特定の要素を検索しようとしていますので、オプション内に検索可能な式があります。また、この要素の値でソートしたいので、value要素に要素範囲インデックスを作成しました。ここに私の検索オプションがうまくいけば明確なものを作るれている:MarkLogic Search API - 検索可能な式と同じ要素で並べ替え順序を行う方法

<options xmlns="http://marklogic.com/appservices/search"> 
     <term> 
      <term-option>case-insensitive</term-option> 
     </term> 
     <debug>true</debug> 
     <searchable-expression>/summary/name/value</searchable-expression> 
     <sort-order type="xs:string" direction="ascending"> 
      <element ns="" name="value"/> 
      <annotation>options for search institutions by name</annotation> 
     </sort-order> 
</options> 

問題は、それが別の値ノードを追加し、ソートを行うとき(検索から撮影:レポートID =「SEARCH-FLWOR」)ということである

...order by xs:string(($result//value)[1]) ascending return $result)[1 to 50] 

の代わりに:私はそれがこれをやって防ぐにはどうすればよい

...order by xs:string(($result)[1]) ascending return $result)[1 to 50] 

?検索可能な式を変更することはできません。「名前」要素には、検索したくない別の子要素があります。また、並べ替え順序の要素名を空白にしたり、現在のノードに設定したりすることはできません。これは簡単だろうが、私はこれを得るために何も見つけ出していない。

助けていただければ幸いです。

答えて

4

あなたは、検索式のターゲット要素として<name>を使用するが、その後のみ<additional-query>を追加することにより、<value>内部を見るにクエリを制限することができます。

<options xmlns="http://marklogic.com/appservices/search"> 
     <term> 
      <term-option>case-insensitive</term-option> 
     </term> 
     <debug>true</debug> 
     <searchable-expression>/summary/name</searchable-expression> 
     <additional-query> 
      <cts:element-query xmlns:cts="http://marklogic.com/cts"> 
      <cts:element>value</cts:element> 
      <cts:and-query/> 
      </cts:element-query> 
     </additional-query> 
     <sort-order type="xs:string" direction="ascending"> 
      <element ns="" name="value"/> 
      <annotation>options for search institutions by name</annotation> 
     </sort-order> 
</options> 
+0

を追加クエリを使用して仕事を得るように思われます。提案していただきありがとうございます。 – Francium123

関連する問題