/// <summary> /// Deletes an entry that matches the specified LuceneEntry. /// </summary> /// /// <param name="myEntry">The entry to be deleted.</param> /// /// <returns> /// 0 (zero) if the operation succeeded; otherwise a value other than 0 (zero). /// </returns> /// /// <exception cref="System.ArgumentNullException"> /// myEntry is NULL. /// </exception> public int DeleteEntry(LuceneEntry myEntry) { if (myEntry == null) { throw new InvalidOperationException("myEntry parameter cannot be null!"); } Term delterm = new Term(LuceneIndex.FieldNames[LuceneIndex.Fields.ID], myEntry.Id); var reader = GetIndexReader(false); int count = reader.DeleteDocuments(delterm); CloseIndexReader(reader); return(count); }
public LuceneResultEntry(LuceneEntry entry) { _VertexID = entry.VertexId; _Highlights = new Dictionary <Int64, string>(); _Score = entry.Score; }
/// <summary> /// Adds the specified entry to the index. /// </summary> /// /// <param name="myEntry">The entry to be added.</param> /// /// <exception cref="System.ArgumentNullException"> /// myEntry is NULL. /// </exception> public void AddEntry(LuceneEntry myEntry) { if (myEntry == null) { throw new InvalidOperationException("Parameter myEntry cannot be null!"); } Document doc = new Document(); Field id = new Field(FieldNames[Fields.ID], myEntry.Id, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO); doc.Add(id); Field indexId = new Field(FieldNames[Fields.INDEX_ID], myEntry.IndexId, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO); doc.Add(indexId); Field vertexId = new Field(FieldNames[Fields.VERTEX_ID], myEntry.VertexId.ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO); doc.Add(vertexId); if (myEntry.PropertyId != null) { Field propertyId = new Field(FieldNames[Fields.PROPERTY_ID], myEntry.PropertyId.ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO); doc.Add(propertyId); } Field text = new Field(FieldNames[Fields.TEXT], myEntry.Text, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS); doc.Add(text); var writer = GetIndexWriter(); writer.AddDocument(doc); CloseIndexWriter(writer); }
/// <summary> /// Deletes an entry that matches the specified LuceneEntry. /// </summary> /// /// <param name="myEntry">The entry to be deleted.</param> /// /// <returns> /// 0 (zero) if the operation succeeded; otherwise a value other than 0 (zero). /// </returns> /// /// <exception cref="System.ArgumentNullException"> /// myEntry is NULL. /// </exception> public int DeleteEntry(LuceneEntry myEntry) { if (myEntry == null) { throw new InvalidOperationException("myEntry parameter cannot be null!"); } Term delterm = new Term(LuceneIndex.FieldNames[LuceneIndex.Fields.ID], myEntry.Id); var reader = GetIndexReader(false); int count = reader.DeleteDocuments(delterm); CloseIndexReader(reader); return count; }