Thanks Geert. Getting results and the query is parsed after adding the 
constraint for "source".

But this seems to be working fine even when there is no constraint added for 
"source" in ML5.

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Geert Josten
Sent: Tuesday, November 15, 2016 1:10 AM
To: MarkLogic Developer Discussion
Cc: Vasiadis, Demetrios
Subject: [MarkLogic Dev General] Re Question #1: MarkLogic 8 Query Parsing 
issues in search:search-Need Help

Hi Banrathi,

Regarding question #1: try adding a word constraint named 'source':

<search:constraint name="source">
<search:word></search:word>
</search:constraint>

Cheers,
Geert

From: 
<general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>>
 on behalf of "Karunanithi, Bharathi" 
<bharathi_karunani...@condenast.com<mailto:bharathi_karunani...@condenast.com>>
Reply-To: MarkLogic Developer Discussion 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Date: Monday, November 14, 2016 at 4:53 PM
To: "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Cc: "Vasiadis, Demetrios" 
<demetrios_vasia...@condenast.com<mailto:demetrios_vasia...@condenast.com>>
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
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to