Results 1 to 1 of 1
Thread: lucene search problem
- 05-10-2012, 12:21 PM #1
Member
- Join Date
- May 2012
- Posts
- 1
- Rep Power
- 0
lucene search problem
Hi All,
I have created indexes on a log file (has values like ip-address and some text) which is comma separated. i indexed it with standardAnalyzer, following is the code of it :
whereas, problem occour when i search numeric values or ip-addresses. it doesn't return result. whereas, with text it is working fine. following is the code snippet :Java Code:indexWriter = new IndexWriter(FSDirectory.open(new File(LUCENE_INDEX_DIRECTORY)), standardAnalyzer, create, IndexWriter.MaxFieldLength.LIMITED); document = new Document(); document.add(new Field("path", path, Field.Store.YES, Field.Index.NO)); document.add(new Field("content", file, Field.Store.NO, Field.Index.ANALYZED)); indexWriter.addDocument(document);
According to my findings - it is analyzer which need to be extended, please help me in solving it and if it is analyser then how to costummize it.Java Code:Qpublic class SearchEngine { private IndexSearcher searcher = null; private QueryParser parser = null; private IndexReader reader = null; private String LUCENE_INDEX_DIRECTORY = "D:\\lucene"; /** Creates a new instance of SearchEngine */ public SearchEngine() throws IOException { File file = new File(LUCENE_INDEX_DIRECTORY); reader = IndexReader.open(FSDirectory.open(file)); searcher = new IndexSearcher(reader); parser = new QueryParser(Version.LUCENE_35, "content", new StandardAnalyzer(Version.LUCENE_35)); } public ScoreDoc[] performSearch(String queryString) throws IOException, ParseException { TopScoreDocCollector collector = TopScoreDocCollector.create(10, false); // Query query = parser.parse(queryString); Query query = new WildcardQuery(new Term("content",queryString+"*")); // Query query = new FuzzyQuery(new Term("content", queryString)); searcher.search(query, collector); ScoreDoc[] hits = collector.topDocs().scoreDocs; System.out.println("Total hits : " +collector.getTotalHits()); return hits; } public IndexSearcher getSearcher() { return searcher; } }
Regards,
Rahul Mathur
Similar Threads
-
Facing problem in lucene search with weblogic clustering server
By samirkumar in forum LuceneReplies: 0Last Post: 08-20-2010, 12:24 PM -
Lucene search with French words
By Maulin in forum LuceneReplies: 1Last Post: 08-18-2010, 05:06 PM -
Lucene search problem with comman words and composite query
By virendra in forum LuceneReplies: 1Last Post: 01-21-2010, 12:40 PM -
SpatialQuery for location based search using Lucene
By simona in forum LuceneReplies: 0Last Post: 06-28-2009, 01:10 AM -
Need help in lucene with hibernate search
By gopalbisht in forum Java SoftwareReplies: 1Last Post: 04-20-2009, 01:54 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks