2011-02-25 23:36:21 +00:00
|
|
|
|
using Lucene.Net.Documents;
|
|
|
|
|
using Lucene.Net.Index;
|
2011-02-26 01:08:38 +00:00
|
|
|
|
using Portoa.Lucene;
|
|
|
|
|
using VideoGameQuotes.Api;
|
2011-02-25 23:36:21 +00:00
|
|
|
|
|
2011-02-26 01:08:38 +00:00
|
|
|
|
namespace VideoGameQuotes.Web.Search {
|
2011-02-25 23:36:21 +00:00
|
|
|
|
public class QuoteDocumentHandler : ILuceneDocumentHandler<Quote> {
|
|
|
|
|
public Document BuildDocument(Quote quote) {
|
|
|
|
|
var document = new Document();
|
|
|
|
|
document.Add(new Field("id", quote.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
|
|
|
|
|
document.Add(new Field("text", quote.Text, Field.Store.YES, Field.Index.ANALYZED));
|
|
|
|
|
return document;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Term GetIdTerm(Quote quote) {
|
|
|
|
|
return new Term("id", quote.Id.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|