Will,

Thank you for information on the snippet I will look into it but as the other 
developers on site have made a workaround wherein they changing the actual 
search term it will be when times given.

Although I'm still curious about why the <matches> path attribute only delivers 
full path when it's not an exact match. 
As I understand it, the @path in the result is not the same as the @path in the 
<result> <matches path><result>

The result path attribute I have gotten to believe is the path sent in into the 
searchable expression
Where the path attribute in the matches element is the or should be the direct 
path to where the match was found this is also the case when not matching 
exactly but as said before when the search term matches exactly the  parent to 
the text element is lost.

However as we got it working with the workaround this question have turned into 
one of more curiosity than urgent need to be solved.

Still would be nice to have an answer if we do something incorrectly or if it 
even might be a bug.

Regards
Erik    


Message: 6
Date: Wed, 20 Jun 2012 17:18:42 +0000
From: Will Thompson <wthomp...@jonesmcclure.com>
Subject: Re: [MarkLogic Dev General] Search:Search result attribute
        path not returning full
To: MarkLogic Developer Discussion <general@developer.marklogic.com>
Message-ID:
        <7A4B442E791E444DB6CA1B9BFA29E92B3613BECC@redman.jmpone.local>
Content-Type: text/plain; charset="iso-8859-1"

Erik,

If you want the matching element, then you could just use the @path from the 
search:result:

doc(&quot;/docbooks/9789144054360.xml&quot;)/book/chapter[1]/section[3]/section[1]/section[1]/title

However, I'm not sure why the search:result path would more specific than the 
search:match path. Alternately, you could write a custom snippet module that 
does exactly what you want.

http://docs.marklogic.com/5.0doc/docapp.xqy#display.xqy?fname=http://pubs/5.0doc/xml/search-dev-guide/search-api.xml%2361707

-Will


-----Original Message-----
From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Erik Zander
Sent: Wednesday, June 20, 2012 2:30 AM
To: general@developer.marklogic.com
Subject: Re: [MarkLogic Dev General] Search:Search result attribute path not 
returning full

Hi
First of all thank you Will for confirming what I have gotten to believe but 
not been entirely sure about that the path must be present in the searchable 
expression.

However this didn't change anything I still miss the title or emphasis or 
whatever tag when I get an exact match on the search term. 

For example with the old path expression I get the following answer when I 
search for Polikliniskt <search:result index="1" 
uri="/docbooks/9789144054360.xml" 
path="fn:doc(&quot;/docbooks/9789144054360.xml&quot;)" score="49152" 
confidence="0.399892" fitness="0.581481">
    <search:snippet>
      <search:match 
path="fn:doc(&quot;/docbooks/9789144054360.xml&quot;)/book/chapter[1]/section[3]/section[1]/section[1]">
<search:highlight>Polikliniskt</search:highlight>

If I change the pat in searchable expression so the options looks like the 
following 

I get the following result
<search:result index="1" uri="/docbooks/9789144054360.xml" 
path="fn:doc(&quot;/docbooks/9789144054360.xml&quot;)/book/chapter[1]/section[3]/section[1]/section[1]/title"
 score="49152" confidence="0.399886" fitness="0.581463">
    <search:snippet>
      <search:match 
path="fn:doc(&quot;/docbooks/9789144054360.xml&quot;)/book/chapter[1]/section[3]/section[1]/section[1]"><search:highlight>Polikliniskt</search:highlight></search:match>
    </search:snippet>

Where the title still is missing in
<search:match 
path="fn:doc(&quot;/docbooks/9789144054360.xml&quot;)/book/chapter[1]/section[3]/section[1]/section[1]"><search:highlight>Polikliniskt</search:highlight></search:match>

I would have expected it to be like the following(spaces introduced around 
change)
<search:match 
path="fn:doc(&quot;/docbooks/9789144054360.xml&quot;)/book/chapter[1]/section[3]/section[1]/section[1]
      /title[1]       
"><search:highlight>Polikliniskt</search:highlight></search:match>

I'm happy for any help 

Regards
Erik

-----Ursprungligt meddelande-----
Fr?n: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] F?r 
general-requ...@developer.marklogic.com
Skickat: den 19 juni 2012 18:28
Till: general@developer.marklogic.com
?mne: General Digest, Vol 96, Issue 35

Send General mailing list submissions to
        general@developer.marklogic.com

To subscribe or unsubscribe via the World Wide Web, visit
        http://community.marklogic.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
        general-requ...@developer.marklogic.com

You can reach the person managing the list at
        general-ow...@developer.marklogic.com

When replying, please edit your Subject line so it is more specific than "Re: 
Contents of General digest..."


Today's Topics:

   1. Re: Search:Search result attribute path not returning full
      path on exact match (Will Thompson)


----------------------------------------------------------------------

Message: 1
Date: Tue, 19 Jun 2012 16:28:13 +0000
From: Will Thompson <wthomp...@jonesmcclure.com>
Subject: Re: [MarkLogic Dev General] Search:Search result attribute
        path not returning full path on exact match
To: MarkLogic Developer Discussion <general@developer.marklogic.com>
Message-ID:
        <7A4B442E791E444DB6CA1B9BFA29E92B361381AB@redman.jmpone.local>
Content-Type: text/plain; charset="iso-8859-1"

Eric,

search:search will only return paths matching your searchable expression. You 
could pass //title as part of your $paths variable, or change your searchable 
expression: 
<searchable-expression>{concat($path,"|//title")}</searchable-expression>.

-Will


From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Erik Zander
Sent: Tuesday, June 19, 2012 8:40 AM
To: general@developer.marklogic.com
Subject: [MarkLogic Dev General] Search:Search result attribute path not 
returning full path on exact match

Hi

I have a problem with the search:search function and the result it gives me.
The problem shows when I for example searches for the word Polikliniskt in the 
following structure


<section>
<title>M?tning av blodtryck</title>
<section>
<title>Polikliniskt</title>
<para>Under normala fysiologiska f?rh?llande f?religger stora variationer i 
blodtryck

The resulting path attribute in the matches element in search result  for 
Polikliniskt do not contains the title element only "//section/section". In 
other words the resulting path is "//section/section" instead of 
"//section/section/title"

This behavior only occurs when the search term exactly matches the text within 
one element so if it's only one word i.e. title above or when quotes are used 
to indicate match exactly like "M?tning av blodtryck".

The search options can be found below for even more information.

  param $searchString (string) The query string
  param $paths (???)
  return (xml) The result
:)



declare function medlib:getSearchResult($searchQueryString, $path) {
  let $options :=
    <options xmlns="http://marklogic.com/appservices/search";>
      <searchable-expression>{$path}</searchable-expression>
      <search-option>score-logtfidf</search-option>
      <search-option>filtered</search-option>
      <page-length>10</page-length>
     (: <return-plan>true</return-plan>:)
      <term>
        <term-option>lang=sv</term-option>
        <term-option>wildcarded</term-option>
        <term-option>case-insensitive</term-option>
        <term-option>whitespace-insensitive</term-option>
        <term-option>punctuation-insensitive</term-option>
        <term-option>diacritic-sensitive</term-option>
        <empty apply="all-results"/>
      </term>
      <transform-results apply="snippet">
        <per-match-tokens>100</per-match-tokens>
        <max-matches>2000</max-matches>
        <max-snippet-chars>40000</max-snippet-chars>
        <preferred-elements/>
      </transform-results>

      <debug>true</debug>
    </options>

  let $result := search:search($searchQueryString, $options)

  return $result



Regards
Erik Zander
Developer @
Studentlitteratur AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://community.marklogic.com/pipermail/general/attachments/20120619/365e6151/attachment.html
 

------------------------------

_______________________________________________
General mailing list
General@developer.marklogic.com
http://community.marklogic.com/mailman/listinfo/general


End of General Digest, Vol 96, Issue 35
***************************************
_______________________________________________
General mailing list
General@developer.marklogic.com
http://community.marklogic.com/mailman/listinfo/general


------------------------------

_______________________________________________
General mailing list
General@developer.marklogic.com
http://community.marklogic.com/mailman/listinfo/general


End of General Digest, Vol 96, Issue 38
***************************************
_______________________________________________
General mailing list
General@developer.marklogic.com
http://community.marklogic.com/mailman/listinfo/general

Reply via email to