次の方法で共有


レコード検索クエリ形式

PeerGroupSearchRecords 関数を呼び出すには、検索の基本的な条件を決定するために使用する XML クエリ文字列パラメーターが必要です。 XML 文字列を作成するには、次のスキーマを使用します。

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="https://www.w3.org/2001/XMLSchema">

  <xs:simpleType name="alphanumType">
     <xs:restriction base="xs:string">
        <xs:pattern value="\c+"/>
     </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="operatorType">
      <xs:choice maxOccurs="unbounded">
         <xs:element ref="and" />
         <xs:element ref="or" />
         <xs:element ref="clause" />
      </xs:choice>
  </xs:complexType>

  <xs:element name="and" type="operatorType"/>

  <xs:element name="or" type="operatorType"/>

  <xs:element name="clause">
      <xs:complexType>
          <xs:simpleContent>
              <xs:extension base="xs:string">
        <xs:attribute name="attrib" type="alphanumType" />
        <xs:attribute name="type">
                  <xs:simpleType>
                    <xs:restriction base="xs:string">
                      <xs:enumeration value="string"/>
                      <xs:enumeration value="date"/>
                      <xs:enumeration value="int"/>
                    </xs:restriction>
                  </xs:simpleType>
                </xs:attribute>
        <xs:attribute name="compare" default="equal">
                  <xs:simpleType>
                    <xs:restriction base="xs:string">
                      <xs:enumeration value="equal"/>
                      <xs:enumeration value="greater"/>
                      <xs:enumeration value="less"/>
                      <xs:enumeration value="notequal"/>
                      <xs:enumeration value="greaterorequal"/>
                      <xs:enumeration value="lessorequal"/>
                    </xs:restriction>
                  </xs:simpleType>
                </xs:attribute>
              </xs:extension>
          </xs:simpleContent>
      </xs:complexType>
  </xs:element>

  <xs:element name="peersearch">
      <xs:complexType>
          <xs:choice>
              <xs:element ref="clause" />
              <xs:element ref="and" />
              <xs:element ref="or" />
          </xs:choice>
      </xs:complexType>
  </xs:element>
</xs:schema> 

レコード検索のプライマリ要素はピアサーチ であり、xmlns 属性に関連付けられているスキーマの URI (Uniform Resource Identifier) が含まれます。 peersearch 子要素として使用する場合は、子要素として 句、または を使用できます。

  • - 要素と 要素は、開始タグと終了タグの間に含まれる 1 つ以上の句に対して論理 AND 操作を実行します。 その他の タグ、タグ、または タグを子にすることができ、その子句の再帰的な結果が操作に含まれます。

    たとえば、James Peters と同じ名前を含むレコードと、2003 年 2 月 28 日より大きい最終更新、または 2003 年 1 月 31 日未満の作成日を含むレコードを取得する場合は、次の XML クエリ文字列を使用します。

    <?xml version="1.0" encoding="utf-8" ?> 
    <peersearch xmlns:xs="https://www.w3.org/2001/XMLSchema">
       <and>
          <clause attrib="peercreatorid" type="string" compare="equal">James Peters</clause>
          <or>
             <clause attrib="peerlastmodificationtime" type="date" compare="greater">2003-01-31</clause>
             <clause attrib="peercreationtime" type="date" compare="less">2003-02-328</clause>
          </or>
       </and>
    </peersearch>
    
  • - 要素は、特定のレコード属性の値と開始タグと終了タグの間に含まれる値を比較する基本的な比較ルールを指定します。 型の と比較 属性は、比較 指定する必要があります。比較 は、実行する比較操作を示します。 たとえば、一致するすべてのレコードを示す単純な検索では、peercreatorid James Peters と等しい値が XML クエリ文字列に次のように表示されます。

    <?xml version="1.0" encoding="utf-8" ?> 
    <peersearch xmlns:xs="https://www.w3.org/2001/XMLSchema">
       <clause attrib="peercreatorid" type="string" compare="equal">James Peters</clause>
    </peersearch>
    

    一般的な 属性には、int文字列、および日付 含まれます。 日付 属性には、https://www.w3.org/TR/NOTE-datetimeで説明されている標準の日付形式のいずれかを指定できます。

    比較 属性の値は、等しい等しい小さい大きい低等、および 等しいです。

  • または - または 要素は、開始タグと終了タグの間に含まれる 1 つ以上の句に対して論理 OR 演算を実行します。 その他の の要素は子にすることができ、子句の再帰的な結果が操作に含まれます。 たとえば、James Peters と等しい名前を含むレコード、または 2003 年 1 月 31 日から 2003 年 2 月 28 日までの最後の更新を含むレコードを取得する場合は、次の XML クエリ文字列を使用します。
<?xml version="1.0" encoding="utf-8" ?> 
<peersearch xmlns:xs="https://www.w3.org/2001/XMLSchema">
   <or>
      <clause attrib="peercreatorid" type="string" compare="equal">James Peters</clause>
      <and>
         <clause attrib="peerlastmodificationtime" type="date" compare="greater">2003-01-31</clause>
         <clause attrib="peerlastmodificationtime" type="date" compare="less">2003-02-28</clause>
      </and>
   </or>
</peersearch>

peersearch の後のノードの最初のレベル 要素は 1 つだけです。 ただし、その要素の後続の子は、同じレベルで多数の要素を持つことができます。

次の検索クエリが正しくありません。

<?xml version="1.0" encoding="utf-8" ?> 
<peersearch xmlns:xs="https://www.w3.org/2001/XMLSchema">
   <clause attrib="peercreatorid" type="string" compare="equal">James Peters</clause>
   <and>
      <clause attrib="peerlastmodificationtime" type="date" compare="greater">2003-01-31</clause>
      <clause attrib="peerlastmodificationtime" type="date" compare="less">2003-02-28</clause>
   </and>
</peersearch>

1 つの true/false 値に解決されずに一致する 2 つの値が返されるため、クエリは失敗します。つまり、1 つの句は James Peters と等しいレコードの名前のクエリであり、AND 演算は 2 つのコンポーネント句に一致します。 結果は、矛盾する 2 つの論理 true/false 値になります。

James Peters と同じ名前を含むすべてのレコードと、2003 年 1 月 31 日から 2003 年 2 月 28 日までの最後の更新プログラムを取得するには、句のを配置し、タグと タグを閉じるのと同じレベルにあるタグを します。 次の例は、成功したクエリを示しています。

<?xml version="1.0" encoding="utf-8" ?> 
<peersearch xmlns:xs="https://www.w3.org/2001/XMLSchema">
    <and>
      <clause attrib="peercreatorid" type="string" compare="equal">James Peters</clause>
      <and>
         <clause attrib="peerlastmodificationtime" type="date" compare="greater">2003-01-31</clause>
         <clause attrib="peerlastmodificationtime" type="date" compare="less">2003-02-28</clause>
      </and>
   </and>
</peersearch>

次の一覧は、クエリを正常に記述するために知っておくべきその他の特定の情報を示しています。

  • 、または タグは、タグ 句を開くタグと閉じる タグの間に配置できません。これは、その構成では、一致する値の一部として解釈され、エラーまたは一致に失敗するためです。
  • 開始タグと終了タグの 、または の各ペアには、少なくとも 1 つ以上の子ノードが含まれている必要があります。
  • このスキーマでは、0 個の要素セットは使用できません。

レコード属性

レコード属性スキーマを使用すると、ユーザーは、句要素の xml 属性 が指定するレコード属性を作成できます。 新しいレコードの属性を追加するには、pszAttributes スキーマで指定された形式を使用して、PEER_RECORD のメンバーを XML 文字列に設定します。

ピア インフラストラクチャは、次の属性名を予約します。

  • peerlastmodifiedby する
  • peercreatorid する
  • peerlastmodificationtime する
  • peerrecordid する
  • peerrecordtype する
  • peercreationtime する
  • peerlastmodificationtime する

特殊文字

一部の文字は、一致するパターンを表現したり、他の特殊文字をエスケープしたりするために使用できます。 これらの文字については、次の表で説明します。

文字パターン 形容
* ワイルドカード文字。 この文字が句値で検出されると、空白文字や英数字以外の文字など、任意の値の 0 ~ n 文字に一致します。 例えば:
"<句 attrib="peercreatorid" type="string" compare="equal">James P*</clause>"
この句は、peercreatorid 値の名が "James" で、姓が "P" で始まる値と一致します。
\* エスケープされたアスタリスク。 このシーケンスはアスタリスク文字と一致します。
? 1 文字のワイルドカード文字。 この文字が句値で検出されると、空白文字や英数字以外の文字を含む任意の 1 文字と一致します。例えば:
"<句 attrib="filename" type="string" compare="equal">data-0?.xml</clause>"
この句は、"data-01.xml" や "data-0B.xml" などのファイル名 一致します。
\? エスケープされた疑問符。 このシーケンスは疑問符文字と一致します。
\\ エスケープされた円記号。 このシーケンスは、1 つの円記号文字と一致します。

文字シーケンスが無効な場合、PeerGroupSearchRecords 関数はエラー E_INVALIDARGを返します。 無効なシーケンスは、"\" (円記号) 文字の直後に "*" (アスタリスク) 文字、"?" が続かないシーケンスです。(疑問符) 文字、または別の "\" (円記号) 文字。