vgquotes/Src/VideoGameQuotes.Web/Search/QuoteDocumentHandler.cs

19 lines
615 B
C#

using Lucene.Net.Documents;
using Lucene.Net.Index;
using Portoa.Lucene;
using VideoGameQuotes.Api;
namespace VideoGameQuotes.Web.Search {
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());
}
}
}