lib-parser tries to emulate google's syntax. It does not implement
"AUTHOR:(john AND smith)" because that isn't google syntax. You are, of
course, free to write your own parser, and you can even use the
apache-licensed lib-parser.xqy code as a starting point.
But first let's look into "(AUTHOR:john AUTHOR:smith)" some more. I
suspect that you might be tickling a bug or misunderstanding an option
(or perhaps you had an extra space before "john"?). Here's my test,
using MarkLogic Server 4.0-2.2 and lib-parser version 3.2-2008-10-08.1
with the built-in code mapping:
import module namespace lp="http://www.marklogic.com/ps/lib/lib-parser"
at "lib-parser.xqy";
lp:get-cts-query('title:foo title:bar')
=>
cts:and-query((cts:element-word-query(QName("", "title"), "foo",
("lang=en"), 1), cts:element-word-query(QName("", "title"), "bar",
("lang=en"), 1)), ())
That's what I'd expect: the output is an and-query of element-word-query
terms (*not* element-query). Note that I omitted AND, because it's a
no-op (as with google's syntax).
From the collection-query in your sample output, it's clear that your
test case must be more complex than mine. Can you provide a full test
case? What result did you expect, and what are you getting? Which
version of the server are you using? What version of lib-parser.xqy do
you have? Have you made any changes to lib-parser-custom.xqy?
-- Mike
On 2008-12-11 00:07, Dave Feldmeier wrote:
I am using lib-parse, and I can do searches like "(AUTHOR: john AND
AUTHOR:smith)". However, this doesn't do the right thing if there are
multiple authors. I want to do a search like "AUTHOR:(john AND smith)",
but lib-parse does not seem to construct the correct expression for this
search. It looks like lib-parse is creating a and-query that combines an
element-query with an empty word query and a second and-query of two
word-queries, rather than creating an element-query with an and-query
that contains two word-queries (see the attached XML of the query).
Since the recursive parser for boolean expressions already exists in
lib-parse, is there an easy way to fix lib-parse to create the correct
search expression when doing a search with boolean expressions within a
field? Thanks.
-Dave
<lib-query>AUTHOR:(john AND smith)</lib-query>
<query>
<cts:and-query xmlns:cts="http://marklogic.com/cts">
<cts:and-query>
<cts:element-query>
<cts:element>AUTHOR</cts:element>
<cts:word-query />
</cts:element-query>
<cts:and-query>
<cts:word-query>
<cts:text xml:lang="en">john</cts:text>
</cts:word-query>
<cts:word-query>
<cts:text xml:lang="en">smith</cts:text>
</cts:word-query>
</cts:and-query>
</cts:and-query>
<cts:collection-query>
<cts:uri>HEAD</cts:uri>
</cts:collection-query>
</cts:and-query>
</query>
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general