1

全体の高さが 4 インチのアイテムを検索:

cts:search の使用について質問があります。次の xml を検討してください。

<Item Id="07123114-5c14-4ba9-a6ad-7b688feb8706" ...>
...
  <AttributeValue AttributeName="Mounting Application" AttributeGroup="Search_Application">Tank</AttributeValue>
  <AttributeValue AttributeName="Type" AttributeGroup="Search_Type">Pump Mounting Bracket</AttributeValue>
  <AttributeValue AttributeName="Overall Width" AttributeGroup="Search_Width">15/16 "</AttributeValue>
  <AttributeValue AttributeName="Overall Height" AttributeGroup="Search_Height">1-3/8 "</AttributeValue>
...
</Item>

全体の高さ = 4" のアイテムを探したいとしましょう。

cts:search で次のクエリを使用しています。

cts:search(/tx:Item,
  cts:element-query(xs:QName("tx:AttributeValue"), cts:and-query((
    cts:element-attribute-value-query(xs:QName("tx:AttributeValue"), xs:QName("AttributeName"), "Overall Height"),
    cts:word-query("4 """, "exact"))))
)

これにより、全体の高さが 4 インチ、1/4 インチ、3/4 インチなどのすべてのアイテムが表示されます。これは、単語クエリが「含む」検索を行うためです。しかし、正確な値の一致. element-value-query は element-query にラップされているため実行できません (element-value はサブ要素ではありません)。

現在、xml 構造を変更する 2 つの方法があります。オプション 1. 値を AttributeValue 要素の属性にする。オプション 2. 子要素にします。

xml 構造を変更せずに探しているものを取得する方法が必要だと思います。お知らせ下さい。

4

2 に答える 2

2

I'd change the XML: use AttributeName to generate meaningful element names.

MarkLogic assumes that your XML has meaningful element and attribute names. This XML structure looks like a perfectly good serialization format. But it's a poor query format because the element names aren't meaningful. It's like a relational database table with three columns: type, group, value. So every query has to join WHERE TYPE=? AND VALUE=?. It's much more efficient to look up values WHERE HEIGHT=?, so MarkLogic pushes you pretty strongly in that direction.

It's technically possible to find ways around this, but you're fighting with the tool. Instead try thinking of the XML as a model for how MarkLogic will build its indexes. When the XML isn't easy to query, change it.

于 2014-06-05T20:47:26.510 に答える
1

あなたの根本的な問題は、トークン化が / とスペースで中断されることです。「2/4」には、あなたが求めている「4」という単語が含まれています。

トークナイザー オーバーライド (ML7) を使用してフィールドを作成し、/ が単語トークンであり、スペースと " が削除されるようにすることで、そこに到達できる場合があります。次に、特定のフィールドの単語クエリをフィールド単語クエリに置き換えます。

ただし、データ モデリングをより詳しく調べることで、あなた自身が有利になるという点については、Michael の意見に同意します。

于 2014-06-05T21:30:29.320 に答える