query.Keys

23 views
Skip to first unread message

Julio Albuquerque

unread,
Dec 17, 2014, 12:57:09 PM12/17/14
to mobile-c...@googlegroups.com
Hi everyone!
I am running the code below:


textSearch.TextChanged += delegate {
                 
if (textSearch.Text.Length > 0) {
                     qry
.Keys = textSearch.Text.ToLower ().Split (' ');
                     qry
.Limit = 50;
                     lines
= qry.Run ();
                     
if (lines.Count > 0) {
                       
...
                     
}
                 
}
             
};

Is working perfectly, but when textSearch.Text has more than one keyword, the result is all the documents that have at least one of the words.
You can make that returns all documents that contain ALL words entered in qry.Keys?

Julio

Jens Alfke

unread,
Dec 17, 2014, 1:34:28 PM12/17/14
to mobile-c...@googlegroups.com

On Dec 17, 2014, at 9:57 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

You can make that returns all documents that contain ALL words entered in qry.Keys?

You'll have to do that yourself, by scanning the view results and keeping track of which keys are found for which document.

—Jens

Julio Albuquerque

unread,
Dec 17, 2014, 2:11:08 PM12/17/14
to mobile-c...@googlegroups.com

Ok Jens.
And how to eliminate duplication?
How indexei by words (your tip in another post), sometimes for the same document is returning several identical because indexei various fields of the document.
Thus a word can be in three fields, for example, resulting in three equal documents.

Jens Alfke

unread,
Dec 17, 2014, 3:02:41 PM12/17/14
to mobile-c...@googlegroups.com

On Dec 17, 2014, at 11:11 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

How indexei by words (your tip in another post), sometimes for the same document is returning several identical because indexei various fields of the document.
Thus a word can be in three fields, for example, resulting in three equal documents.

In your map function, collect the words into a set data structure to eliminate duplicates, before emitting them. (Do the same thing when querying, in case the query has duplicate words. In fact, the whole function that takes a string and returns a set of words should be shared between the map function and the query code.)

I used to have an O'Reilly book (circa 2008) that explained the basics of various search techniques like web-crawling and full-text indexing, with examples in Python. I can't remember the title, though.

—Jens
Reply all
Reply to author
Forward
0 new messages