Chakri
Chakri

Reputation: 23

Indexing and searching special characters like '@','#' in lucene

I am indexing fields using StandardAnlyzer which removes punctuations from the input string. My input string contains special characters like @, # , -, etc.

Eg: The indexed data may consist of values like userid: AB@234, ABC#DF

I am trying to update the index passing BooleanQuery uesrid: ABC@34 to delete previous documents using writer.deletedocuments(query); and the update the index using writer.updateDocuments(Term,document);

Deleting the current indexex using above query delete all the values that starts with ABC@.i.e, the documents with userid values ABC@123, ABC@55, etc. are also deleted.

Could any one suggest a solution to index and update specific document containing above special characters.

Any suggession is highly appreciated.

Thank in advance.

Chakradhar

Upvotes: 1

Views: 2998

Answers (1)

jpountz
jpountz

Reputation: 9964

The best option is probably to use KeywordAnalyzer to index your userid field and then use IndexWriter.deleteDocuments(Term) to delete documents.

Upvotes: 2

Related Questions