java - mysql contains search in Lucene -


i trying implement contains search in lucene. example, consider 2 documents

  • apple mango (say 1st document)
  • apple orange mango (say 2nd document)

if search "*ple man*", want 1st document alone , not second document. achieved indexing field values not_analysed.

  public class test {     public static void main(string[] args) throws exception {         analyzer analyzer = new classicanalyzer(version.lucene_30, new stringreader(""));         directory dir = new niofsdirectory(new file("/home/test"));         indexwriterconfig config = new indexwriterconfig(version.latest, analyzer);         indexwriter indexwriter = new indexwriter(dir, config);         string names[]=new string[]{"apple mango", "apple orange mango"};         document doc;         for(int i=0;i<names.length;i++){             doc = new document();             doc.add(new field("name",names[i], field.store.yes, field.index.not_analyzed));             indexwriter.adddocument(doc);         }         indexwriter.close();          indexreader indexreader = directoryreader.open(dir);         indexsearcher indexsearcher = new indexsearcher(indexreader);         queryparser queryparser=new queryparser("name",analyzer);         queryparser.setallowleadingwildcard(true);          query query= queryparser.parse("*ple\\ man*");         topdocs docs = indexsearcher.search(query, 1000);         indexreader.close();     } } 

is there way achieve if index fields analysed?


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -