I don't have time right now to debug your code right now, but make sure that the analysis is consistent between index and query. For example, "Apache" vs. "apache".

-- Jack Krupansky

-----Original Message----- From: Bratislav Stojanovic
Sent: Saturday, March 16, 2013 7:29 AM
To: java-user@lucene.apache.org
Subject: Re: Getting documents from suggestions

Hey Jack,

I've tried MoreLikeTHis, but it always returns me 0 hits. Here's the code,
it's very simple :

// test2
Index lucene = null;
try {
lucene = new Index();
MoreLikeThis mlt = new MoreLikeThis(lucene.reader);
mlt.setAnalyzer(lucene.analyzer);
Reader target = new StringReader("apache");
Query query = mlt.like(target, "contents");
TopDocs results = lucene.searcher.search(query, 10);
ScoreDoc[] hits = results.scoreDocs;
System.out.println("Total "+hits.length+" hits");
for (int i = 0; i < hits.length; i++) {
Document doc = lucene.searcher.doc(hits[i].doc);
System.out.println("Hit "+i+" : "+doc.getField("id").stringValue());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (lucene != null) lucene.close();
}

Here are my fields in the index :

...
Field pathField = new StringField("path", file.getPath(), Field.Store.YES);
doc.add(pathField);

doc.add(new LongField("modified", file.lastModified(), Field.Store.NO));
// id so we can fetch metadata
doc.add(new LongField("id", id, Field.Store.YES));
// add default user (guest)
doc.add(new LongField("userid", -1L, Field.Store.YES));

doc.add(new TextField("contents", new BufferedReader(new
InputStreamReader(fis, "UTF-8"))));
...

Do you have any clue what might be wrong? Btw, searching for "apache"
returns me 36 hits, so index is fine.

P.S. I even tried like(int) and passing Doc. Id. but same thing.

On Thu, Mar 14, 2013 at 10:45 PM, Jack Krupansky <j...@basetechnology.com>wrote:

Could you give us some examples of what you expect? I mean, how is your
suggested set of documents any different from simply executing a query with
the list of suggested terms (using q.op=OR)?

Or, maybe you want something like MoreLikeThis?

-- Jack Krupansky

-----Original Message----- From: Bratislav Stojanovic
Sent: Thursday, March 14, 2013 5:36 PM
To: java-user@lucene.apache.org
Subject: Getting documents from suggestions


Hi all,

How can I filter suggestions based on some value from the indexed field?
I have a stored 'id' field in my index and I want to use that to examine
documents
where the suggestion was found, but how to get Document from suggestion?
SpellChecker class only returns array of strings.

What classes should I use? Please help.

Thanx in advance.

--
Bratislav Stojanovic, M.Sc.

------------------------------**------------------------------**---------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.**apache.org<java-user-unsubscr...@lucene.apache.org> For additional commands, e-mail: java-user-help@lucene.apache.**org<java-user-h...@lucene.apache.org>




--
Bratislav Stojanovic, M.Sc.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to