Thanks Lan for reply.

cpn values are like 123-0049, 342-043, ab23-090, hedwsdg

my application is working when i gave search  for below inputs
1) ab*
 2)hedwsdg
3) hed*

but it is not working for
1) 123*
2) 123-0049
3) ab23*


Note: if the search input has number then it is not working.

Thanks in advacne.


On Mon, Sep 28, 2015 at 3:49 PM, Ian Lea <ian....@gmail.com> wrote:

> Hi
>
>
> Can you provide a few examples of values of cpn that a) are and b) are
> not being found, for indexing and searching.
>
> You may also find some of the tips at
>
> http://wiki.apache.org/lucene-java/LuceneFAQ#Why_am_I_getting_no_hits_.2F_incorrect_hits.3F
> useful.
>
> You haven't shown the code that created the IndexWriter so the tip
> about using the same analyzer at index and search time might be
> relevant.
>
>
>
> --
> Ian.
>
>
> On Mon, Sep 28, 2015 at 10:49 AM, Bhaskar <bhaskar1...@gmail.com> wrote:
> > Hi,
> > I am beginner in Apache lucene, I am using 5.3.1.
> > I have created  the index on the database result. The index values are
> > having alphanumeric and strings values. I am able to search the strings
> but
> > I am not able to search alphanumeric values.
> >
> > Can someone help me here.
> >
> > Below is indexing code...
> >
> > int indexDocs(IndexWriter writer, Connection conn) throws Exception {
> > Statement stmt = conn.createStatement();
> >   ResultSet rs = stmt.executeQuery(sql);
> >   int i=0;
> >   while (rs.next()) {
> >      Document d = new Document();
> >     // System.out.println("cpn is" + rs.getString("cpn"));
> >     // System.out.println("mpn is" + rs.getString("mpn"));
> >
> >   d.add(new TextField("cpn", rs.getString("cpn"), Field.Store.YES));
> >
> >
> >      writer.addDocument(d);
> >      i++;
> >  }
> > }
> >
> > Searching code:
> >
> >
> > private void searchIndex(Path indexDir, String queryStr) throws
> Exception {
> > Directory directory = FSDirectory.open(indexDir);
> > System.out.println("The query string is " + queryStr);
> > // MultiFieldQueryParser queryParser = new MultiFieldQueryParser(new
> > // String[] {"mpn"}, new StandardAnalyzer());
> > // IndexReader reader = IndexReader.open(directory);
> > IndexReader reader = DirectoryReader.open(directory);
> > IndexSearcher searcher = new IndexSearcher(reader);
> > Analyzer analyzer = new StandardAnalyzer();
> > analyzer.tokenStream("cpn", queryStr);
> > QueryParser parser = new QueryParser("cpn", analyzer);
> > parser.setDefaultOperator(Operator.OR);
> > parser.getAllowLeadingWildcard();
> > parser.setAutoGeneratePhraseQueries(true);
> > Query query = parser.parse(queryStr);
> > searcher.search(query, 100);
> > TopDocs topDocs = searcher.search(query, MAX_HITS);
> >
> > ScoreDoc[] hits = topDocs.scoreDocs;
> > System.out.println(hits.length + " Record(s) Found");
> > for (int i = 0; i < hits.length; i++) {
> > int docId = hits[i].doc;
> > Document d = searcher.doc(docId);
> > System.out.println("\"value is:\" " + d.get("cpn"));
> > }
> > if (hits.length == 0) {
> > System.out.println("No Data Founds ");
> > }
> >
> >
> > Thanks in advance.
> >
> > --
> > Keep Smiling....
> > Thanks & Regards
> > Bhaskar.
> > Mobile:9866724142
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


-- 
Keep Smiling....
Thanks & Regards
Bhaskar.
Mobile:9866724142

Reply via email to