Hi, Blessing:
I'm glad to hear that was a start.
For the simple case shown, I just turned on the "trailing wildcard searches"
indexing option before executing a word query. As you likely know, MarkLogic
gives you lots of knobs for tuning the indexes to optimize different kinds of
queries and resource usage. The optimal tuning depends on your data set and
queries. For many data sets, default stemming supports the query requirements
so there's no need for wildcards.
Sections of the documentation that might be helpful:
http://docs.marklogic.com/guide/search-dev/wildcard#id_66278
http://docs.marklogic.com/guide/search-dev/stemming
http://docs.marklogic.com/guide/search-dev/wildcard
One other thing to consider -- you could define an "author" field on the name
element within the author element and declare a field constraint for that field
to restrict "author" queries to author/name.
Hoping that helps,
Erik Hennum
________________________________________
From: [email protected]
[[email protected]] on behalf of Blessing N
[[email protected]]
Sent: Tuesday, October 01, 2013 3:23 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Issue with Wildcard search in
cts:element-query
Hi Erik,
Thanks for your response. Your answer was very useful.
I tried word constraint on "Author" element, but was not working as
expected until I created a Phrase Through for "Author" element.
Do you mean we have to create Phrase Through in order to achieve this
using a word constraint?
Thanks,
Blessing.
On Fri, Sep 27, 2013 at 9:22 PM, Erik Hennum <[email protected]> wrote:
> Hi, Blessing:
>
> A couple of issues:
>
> * Term options are only valid for term, word, and value queries. If you
> add <debug>true</debug> to the options, you'll see that the Search API is
> dropping the term options.
>
> * I think you probably want a word constraint on an element rather than an
> element query. An element query specifies an element container for nested
> queries scoped to that element.
>
> With a suitable database configuration, the following worked for me:
>
> let $QUERY-OPTIONS := (<search:term-option>wildcarded</search:term-option>,
>
>
> <search:term-option>case-insensitive</search:term-option>,
>
> <search:term-option>diacritic-insensitive</search:term-option>,
> <search:term-option>unstemmed</search:term-option>
> )
> let $OPTIONS := <options xmlns="http://marklogic.com/appservices/search">
> <constraint name="Author">
> <word>
> <element ns="" name="Author"/>
> {$QUERY-OPTIONS}
> </word>
> </constraint>
> <page-length>1000</page-length>
> <debug>true</debug>
>
> </options>
> let $query := "Author:Peter*"
> return search:search($query,$OPTIONS)
>
>
> Hoping that's useful,
>
>
> Erik Hennum
>
> ________________________________
> From: [email protected]
> [[email protected]] on behalf of Blessing N
> [[email protected]]
> Sent: Friday, September 27, 2013 12:56 AM
> To: [email protected]
> Subject: [MarkLogic Dev General] Issue with Wildcard search in
> cts:element-query
>
> Hi,
>
> I have records as follows
>
> <record>
> <Author>
> <Name>Peter</Name>
> <City>NewYork</City>
> </Author>
> <Editor>
> <Name>Steven</Name>
> <City>Virginia</City>
> </Editor>
> </record>
>
> <record>
> <Author>
> <Name>Smith</Name>
> <City>Phoenix</City>
> </Author>
> <Editor>
> <Name>Peter Jackson</Name>
> <City>Washington</City>
> </Editor>
> </record>
>
> My requirement is to find Author/Name starting with "Peter*" which should
> return only the first record. However the following code returns both the
> record where "Peter*" is present in Editor/Name
>
>
> declare variable $mynamespace := "http://some.com/mynamespace";
> declare variable $QUERY-OPTIONS :=
> (<search:term-option>wildcarded</search:term-option>,
>
> <search:term-option>case-insensitive</search:term-option>,
>
> <search:term-option>diacritic-insensitive</search:term-option>,
>
> <search:term-option>unstemmed</search:term-option>
> );
>
> declare variable $OPTIONS := <options
> xmlns="http://marklogic.com/appservices/search">
> <constraint name="Author">
> <element-query ns="{$mynamespace}"
> name="Author" />
> {$QUERY-OPTIONS}
> </constraint>,
> <page-length>1000</page-length>,
>
>
> </options>;
> let $query := "Author:Peter*"
> let $results := search:search($query,$OPTIONS)
> return $results
>
> This is the query formed
>
> <search:report id="SEARCH-FLWOR">(cts:search(fn:collection(),
> cts:element-query(xs:QName("mynamespace:Author"), cts:word-query("Peter*",
> ("lang=en"), 1), ()), ("score-logtfidf"), 1))[1 to 1000]</search:report>
>
> I found this issue only with Wildcard search in cts:element-query whereas
> "Author:Peter" works perfectly. Is this a known issue or do i have to modify
> my implementation.
>
> Thanks
>
>
>
>
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general