Kelly:

My real problem is that we need to do keyword search on all documents that are 
referenced by the current document with N level. For example user is reading 
doc1, he want to do a keyword search among all documents whichdoc1 reference to 
(1st level friend documents) plus all documents that 1st level friends 
reference to (friend of friend) to 7 level deep. I have a recursive function to 
find out all friend documents for doc1 up to 7 level which return about 200,000 
doc urls. Then I need to do keyword search among these friends document.

You have a better way to do that?
 
Ningjun Wang
Consulting Software Engineer
 
LexisNexis Global Solutions Dev
New Providence, NJ
(908) 665-6787

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Kelly Stirman
Sent: Wednesday, June 22, 2011 3:11 PM
To: [email protected]
Subject: Re: [MarkLogic Dev General] How to do keyword search within a set of 
dicuments returned by some function.

This may solve the immediate problem, but I don't think it is a great solution.

The standard way of searching within a set of results is to AND the query with 
the new constraints and issue a new query. If your application design doesn't 
allow you to know the query that generates the first set of results, then I 
think you may need to rethink the design. Unfortunately, we don't always have 
that luxury. :)

Kelly

Message: 1
Date: Wed, 22 Jun 2011 18:07:23 +0000
From: "Wang, Ningjun (LNG-NPV)" <[email protected]>
Subject: Re: [MarkLogic Dev General] How to do keyword search within a
        set of dicuments returned by some function.
To: General MarkLogic Developer Discussion
        <[email protected]>
Message-ID:
        <1533716386a4d547ad15701487022d4822b37...@retdaymbxp004.legal.regn.net>
        
Content-Type: text/plain; charset="us-ascii"

Damon:

Your suggestion works great. Thanks for the help.


Ningjun Wang

From: [email protected] 
[mailto:[email protected]] On Behalf Of Damon Feldman
Sent: Friday, June 10, 2011 11:24 AM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to do keyword search within a set of 
dicuments returned by some function.

Ningjun,

I believe you want to use a cts:document-query() with the thousands of URI's to 
constrain your search. Set this as an <additional-query> in search:search().

That's if your restriction is on the MarkLogic URIs for each document. If you 
actually have URL's encoded in the documents in a <url> element or similar, use 
cts:element-value-query(xs:QName("url"), $doc-urls) as the additional query.

Yours,
Damon

From: [email protected] 
[mailto:[email protected]] On Behalf Of Wang, Ningjun 
(LNG-NPV)
Sent: Friday, June 10, 2011 10:14 AM
To: General MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] How to do keyword search within a set of 
dicuments returned by some function.

We have a requirement to do keyword search on a set of documents returned by 
some function. For example the function getRelatedDocUrls() return a list of 
document URLs (could be hundreds of thousands of document). I need to do a 
keyword search within those documents and return the correct total count and 
return result with 10 documents per page. What is the most efficient way to do 
that?

One option I am thinking is to do the keyword search first then join the result 
with the set of documents, e.g.

Let $urls := getRelatedDocUrls()
for $result in search:search(keyword)/search:result, $url in $urls where 
$result/@uri = $url

There are two problems

1.      search:search(keyword) return one page at a time. Suppose I make it 
return 20 docs per page, then the first page may not have any document matching 
$urls.

2.      search:search(keyword) return the total count of document matching 
keyword. However I want the total count of documents not only matching the 
keyword, but also with url in $urls

Of course I can make search:search(keyword) to return all result in one page 
and then through the join to find out the answer above. However this will be 
very inefficient because search:search(keyword) can return millions of 
documents. I just want the correct total count and the first 10 documents that 
match the keyword and with url match $urls.

What is the most efficient way to do this?

Thanks



Ningjun Wang
Consulting Software Engineer

LexisNexis Global Solutions Dev
New Providence, NJ
(908) 665-6787
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to