Skip to content

Instantly share code, notes, and snippets.

@sirkirby
Last active January 3, 2016 09:59
Show Gist options
  • Select an option

  • Save sirkirby/8446352 to your computer and use it in GitHub Desktop.

Select an option

Save sirkirby/8446352 to your computer and use it in GitHub Desktop.
Azure Full Text Search Ex 2
var indexWriter = new IndexWriter(directory, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), true,
new IndexWriter.MaxFieldLength(IndexWriter.DEFAULT_MAX_FIELD_LENGTH));
foreach (var book in Books)
{
var document = new Document();
// store the Id but don't need to index it
document.Add(new Field("Id",
book.BookId.ToString(),
Field.Store.YES,
Field.Index.NO,
Field.TermVector.NO));
document.Add(new Field("Title",
book.Title,
Field.Store.YES,
Field.Index.ANALYZED,
Field.TermVector.NO));
document.Add(new Field("Author",
book.Author ?? "",
Field.Store.YES,
Field.Index.ANALYZED,
Field.TermVector.NO));
document.Add(new Field("CoAuthor",
book.CoAuthor ?? "",
Field.Store.YES,
Field.Index.ANALYZED,
Field.TermVector.NO));
indexWriter.AddDocument(document);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment