Hi Justin,

I misstated what I meant.  I encountered a problem in converting my
cts:and-query to  the "serialized and annotated cts:query" required by
search:resolve.  I tried to convert it with
search:parse(xdmp:quote($and-query)), but the resulting cts:and-query is
not what I would expect.  For example, here is the cts:and-query before
parsing:

<cts:and-query xmlns:cts="http://marklogic.com/cts>
  <cts:element-query>
    <cts:element>MyElementName</cts:element>
    <cts:and-query>
        <cts:element-attribute-value-query>
          <cts:element>MyElementName</cts:element>
 
<cts:attribute>MyAttributeName</cts:attribute>
                           <cts:text
xml:lang="en">text_to_match</cts:text>
                     </cts:element-attribute-value-query>
          </cts:and-query>
    </cts:element-query>
<cts:and-query>

Here is the (start of) the parsed result:

<cts:and-query strength="20" xmlns:cts="http:marklogic.com/cts">
  <cts:word-query qtextref="cts:text">
    <cts:text>cts:and-query(cts:element-query(xs:QName(</cts:text>
  </cts:word-query>
  <cts:and-query strength ="20">
    <cts:word-query qtextpre=""" qtextref="cts:text" qtextpost=""">
        <cts:text>MyElementName</cts:text>
    </cts:word-query>
  <cts:and-query strength="20">
    <cts:word-query qtextref="cts:text">
      <cts:text>)</cts:text>
    </cts:word-query>
    <cts:word-query qtextref="cts:text">
      <cts:text>,</cts:text>
    </cts:word-query>
....
</cts:and-query>

As the above shows, the parsed version seems to be breaking up the
original query into word queries that contain the text of the
cts:queries including separate word queries for punctuation within the
xs:QName constructor.  Naturally, I get no results when I pass this to
search:resolve.

Attempting to pass the cts:and-query directly to search:resolve results
in an error stating that it cannot be coerced into an element().  So the
question is how do I convert my cts:and-query into a
schema-element(cts:query)?

Bob

------------------------------------------------------------------------
------------------------------------------------
Bob,
As you've indicated, search:search allows you to go end-to-end from a
query string (e.g. oil OR gas published:yesterday) to to a
search:response report which includes result snippets, facets, and other
features specified in the options parameter. search:resolve allows you
to bypass the query parsing by supplying your own cts:query element
rather than a raw query string. I'm not quite sure what you mean by "I
considered using search:resolve but that requires my query to be a
string." I can probably better guide you with some code to illustrate
what you've tried.

Justin

On Feb 15, 2010, at 7:56 AM, Runstein, Robert E. (Contr) (IS) wrote:


Hi All,

I'm building a feature that allows advanced users to specify a query by
submitting an XML document containing elements and attributes whose
values specify the element and attribute values that the results should
match on.  Users have the freedom to submit documents containing new
elements that they want to query on and we want them to be able to do
this without our having to create new indexes and option constraints
each time they add a new element.  I call this query by example.

I've done this by creating  a cts:element-query for each element.  The
query wraps a cts:and-query of the element's text (if any) as a
cts:word-query and each attribute's text as a
cts:element-attribute-value-query.  The resulting cts:element-querys are
combined in a cts:and-query.

The issue that I'm having is that I want to do a search:search to get a
search:response rather than a cts:search that gives me the full content
of the matching documents.  I can achieve this by including my
cts:and-query as an additional-query within my search:options and
leaving the qtext empty.

I considered using search:resolve but that requires my query to be a
string.  I tried using xmdp:quote and search:parse on my cts:and-query,
but that just mangles the query and does not return results.

Is including my generated query as an additional-query to search:search
options the best way to do this or is there a way to convert my
cts:and-query to a string for search:resolve that won't mangle it, or is
there a better approach to implementing query by example than the path I
have followed?


Thanks.

Bob

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to