vgquotes/Src/VideoGameQuotes.Api/Search/Lucene/QuoteDocumentHandler.cs

18 lines
574 B
C#
Raw Normal View History

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