Sorry, I see no options. The return-query flag is tucked deep into the search 
lib.

If you consider this a serious restriction, I’d advice reaching out via your 
MarkLogic support channels, and ask to get an RFE (Request for Enhancement) 
raised..

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of "Karunanithi, Bharathi" 
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Tuesday, November 15, 2016 at 1:02 PM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Cc: "Vasiadis, Demetrios" 
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Re Question #2: MarkLogic 8 Query Parsing 
issues in search:search-Need Help

Thanks Geert. Yes, Now I am able to see the annotated query using 
"cts:annotated-query” option in search:parse.

But I need this to be returned in search:search response when the 
<return-query> flag is set to “true”. But by default, this is returning a 
“cts-query” not the annotated query.

So as you suggested ,  got the annotated query separately using the 
“cts:annotated-query” option in search:parse as highlighted below:

<output>
                <facetResponse>{search:search($query, 
$options,0,1)}</facetResponse>
                <annotatedQuery>{search:parse($query, $options, 
"cts:annotated-query")}</annotatedQuery>
            </output>

This again results in an extra step to get the annotated-query. Can we get an 
annotated-query in search:search response in a single step(results as well as 
the annotated query as a single response)?

Thanks,
Bharathi K
From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Geert Josten
Sent: Tuesday, November 15, 2016 1:16 AM
To: MarkLogic Developer Discussion
Cc: Vasiadis, Demetrios
Subject: [MarkLogic Dev General] Re Question #2: MarkLogic 8 Query Parsing 
issues in search:search-Need Help

Hi Bharathi,

Regarding question #2, I think you refer to the cts:query annotations that 
where originally used for search:unparse. Search:unparse has been deprecated 
though (see http://docs.marklogic.com/search:unparse), hence the change in the 
default behavior of search:parse. You can still get the annotated cts:query by 
providing an extra flag. Just append , "cts:annotated-query” to the call to 
search:parse. See also the example shown in above link..

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of "Karunanithi, Bharathi" 
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Monday, November 14, 2016 at 4:53 PM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Cc: "Vasiadis, Demetrios" 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] MarkLogic 8 Query Parsing issues in 
search:search-Need Help

Hi Team,
We are doing an Application migration from MarkLogic 5.0-5 to 8.0-4. In which 
we observe certain query parsing issues.
Issue:

We have been getting no results for the:

query string: publication:"Bon Appetit" AND coverDisplayDate:"October 2016" AND 
regionName:"United States" AND source:"Pre-press"

Some parameters returned are different between ML versions.

Sample Query Snippet:
import module namespace model = "http://condenast.com/dam/2.0/model/montrose"; 
at "/application/model/montrose-model.xqy";
import module namespace search = "http://marklogic.com/appservices/search"; at 
"/MarkLogic/appservices/search/search.xqy";
declare namespace cndam = "http://condenast.com/dam/2.0";;

 let $query := 'publication:"Bon Appetit" AND coverDisplayDate:"October 2016" 
AND regionName:"United States" AND source:"Pre-press"'
return search:parse($query, model:build-all-options("Image"))

Attaching the search options used.(please refer options.txt)

ML5 result:
<cts:and-query qtextjoin="AND" strength="20" qtextgroup="( )" 
xmlns:cts="http://marklogic.com/cts"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
  <cts:and-query qtextjoin="AND" strength="20" qtextgroup="( )">
    <cts:and-query qtextjoin="AND" strength="20" qtextgroup="( )">
      <cts:element-range-query qtextpre="publication:" 
qtextref="cts:annotation" operator="=">
            <cts:element 
xmlns:_1="http://condenast.com/dam/2.0";>_1:publicationName</cts:element>
            <cts:annotation qtextpre="&quot;" 
qtextref="following-sibling::cts:value" qtextpost="&quot;"/>
            <cts:value xsi:type="xs:string" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>Bon Appetit</cts:value>
            
<cts:option>collation=http://marklogic.com/collation/codepoint</cts:option><http://marklogic.com/collation/codepoint%3c/cts:option%3e>
      </cts:element-range-query>
      <cts:element-word-query qtextpre="coverDisplayDate:" 
qtextref="cts:annotation">
            <cts:element 
xmlns:_1="http://condenast.com/dam/2.0";>_1:coverDisplayDate</cts:element>
            <cts:annotation qtextpre="&quot;" 
qtextref="following-sibling::cts:text" qtextpost="&quot;"/>
            <cts:text>October 2016</cts:text>
      </cts:element-word-query>
    </cts:and-query>
    <cts:element-range-query qtextpre="regionName:" qtextref="cts:annotation" 
operator="=">
      <cts:element 
xmlns:_1="http://condenast.com/dam/2.0";>_1:region</cts:element>
      <cts:annotation qtextpre="&quot;" qtextref="following-sibling::cts:value" 
qtextpost="&quot;"/>
      <cts:value xsi:type="xs:string" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>United States</cts:value>
      
<cts:option>collation=http://marklogic.com/collation/codepoint</cts:option><http://marklogic.com/collation/codepoint%3c/cts:option%3e>
    </cts:element-range-query>
  </cts:and-query>
  <cts:word-query qtextpre="source:&quot;" qtextref="cts:text" 
qtextpost="&quot;">
    <cts:text>Pre-press</cts:text>
  </cts:word-query>
</cts:and-query>

ML8 result:
<cts:and-query xmlns:cts="http://marklogic.com/cts";>
  <cts:element-range-query operator="=">
    <cts:element 
xmlns:_1="http://condenast.com/dam/2.0";>_1:publicationName</cts:element>
    <cts:value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>Bon Appetit</cts:value>
    
<cts:option>collation=http://marklogic.com/collation/codepoint</cts:option><http://marklogic.com/collation/codepoint%3c/cts:option%3e>
  </cts:element-range-query>
  <cts:element-word-query>
    <cts:element 
xmlns:_1="http://condenast.com/dam/2.0";>_1:coverDisplayDate</cts:element>
    <cts:text xml:lang="en">October 2016</cts:text>
  </cts:element-word-query>
  <cts:element-range-query operator="=">
    <cts:element xmlns:_1="http://condenast.com/dam/2.0";>_1:region</cts:element>
    <cts:value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>United States</cts:value>
    
<cts:option>collation=http://marklogic.com/collation/codepoint</cts:option><http://marklogic.com/collation/codepoint%3c/cts:option%3e>
  </cts:element-range-query>
  <cts:word-query>
    <cts:text xml:lang="en">source:Pre-press</cts:text>
    <cts:option>case-insensitive</cts:option>
    <cts:option>diacritic-insensitive</cts:option>
    <cts:option>wildcarded</cts:option>
  </cts:word-query>
</cts:and-query>

Question 1: Why is there a difference in the query formation for 
source:”Pre-press” in the word-query?

ML5

ML8

<cts:word-query qtextpre="source:&quot;" qtextref="cts:text" qtextpost="&quot;">
    <cts:text>Pre-press</cts:text>


<cts:word-query>
    <cts:text xml:lang="en">source:Pre-press</cts:text>
    <cts:option>case-insensitive</cts:option>
    <cts:option>diacritic-insensitive</cts:option>
    <cts:option>wildcarded</cts:option>
  </cts:word-query>

Do we miss any of the ML configuration which renders such a query formation in 
ML8?
I have been trying to pass only “Pre-press” as the query string instead of 
‘source:”Pre-press”’. Though it fetches the results, it breaks the facets 
response in search:response , the concept behind is we need to apply a source 
filter and show that it is applied to the front end

Question 2:
In MarkLogic 5: search:parse response is having the facet information. Along 
with this, we find search:query which contains all the currently selected 
facets and the search terms with the facet names and values in qtextpre and 
qtextpost, and in the cts:text.
But in ML8, this structure is more generic as seen below, we could not find the 
aaplied facet name details in the new xml structure. Attaching the logic used 
in the application to build the facets from search:response.(please refer 
build-facets.xqy)

<search:response snippet-format="raw" total="767" start="1" page-length="1" 
xmlns:search="http://marklogic.com/appservices/search";>
            <search:facet name="publication" type="xs:string">
                        <search:facet-value name="Bon Appetit" count="767">Bon 
Appetit</search:facet-value>
            </search:facet>
            <search:facet name="source" type="xs:string">
                        <search:facet-value name="Pre-press" 
count="767">Pre-press</search:facet-value>
            </search:facet>
            <search:facet name="regionName" type="xs:string">
                        <search:facet-value name="United States" 
count="767">United States</search:facet-value>
            </search:facet>
            <search:qtext>publication:"Bon Appetit" AND 
coverDisplayDate:"October 2016" AND regionName:"United States" AND 
source:"Pre-press"</search:qtext>
            <search:query>
                        <cts:and-query xmlns:cts="http://marklogic.com/cts";>
                                    <cts:element-range-query operator="=">
                                                <cts:element 
xmlns:_1="http://condenast.com/dam/2.0";>_1:publicationName</cts:element>
                                                <cts:value 
xsi:type="xs:string">Bon Appetit</cts:value>
                                                
<cts:option>collation=http://marklogic.com/collation/codepoint</cts:option><http://marklogic.com/collation/codepoint%3c/cts:option%3e>
                                    </cts:element-range-query>
                                    <cts:element-word-query>
                                                <cts:element 
xmlns:_1="http://condenast.com/dam/2.0";>_1:coverDisplayDate</cts:element>
                                                <cts:text xml:lang="en">October 
2016</cts:text>
                                    </cts:element-word-query>
                                    <cts:element-range-query operator="=">
                                                <cts:element 
xmlns:_1="http://condenast.com/dam/2.0";>_1:region</cts:element>
                                                <cts:value 
xsi:type="xs:string">United States</cts:value>
                                                
<cts:option>collation=http://marklogic.com/collation/codepoint</cts:option><http://marklogic.com/collation/codepoint%3c/cts:option%3e>
                                    </cts:element-range-query>
                                    <cts:element-range-query operator="=">
                                                <cts:element 
xmlns:_1="http://condenast.com/dam/2.0";>_1:sourceGroup</cts:element>
                                                <cts:value 
xsi:type="xs:string">Pre-press</cts:value>
                                                
<cts:option>collation=http://marklogic.com/collation/codepoint</cts:option><http://marklogic.com/collation/codepoint%3c/cts:option%3e>
                                    </cts:element-range-query>
                        </cts:and-query>
            </search:query>
</search:response>

ML8 is offering a very generic query structure when compared with the ML5 
version. It was very helpful and easier with the older parse response to build 
the faceting applications for showing the applied facets and also to remove the 
applied filters easily.

Appreciating your help in getting better faceting results in ML8 as in ML5. Is 
there any way to get the parse response in ML8 as in ML5? or is it mandatory to 
change the logic to support in ML8?
Please correct me if I am missing any.

Thanks,
Bharathi K


_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to