Note that there are some explanatory texts on larger screens.

plurals
  1. POLucene.Net search like a071,a072,a073
    primarykey
    data
    text
    <p>Enviroment : </p> <p>Lucene.Net 3.03</p> <p>Visual Studio 2010</p> <hr> <p>I've been stuck on this problem for hours at this point and I can't figure out the problem.</p> <p>i build some index named "Stores" , the format like below , </p> <p>a075,a073,a021....</p> <p>each string represent the id of shop , and it Separated by "," , </p> <p>i would like search "a073" , and it will return matched data if the "Stores" include "a073" </p> <p>thanks in advance</p> <pre><code>static RAMDirectory dir = new RAMDirectory(); public void BuildIndex() { IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_30), true, IndexWriter.MaxFieldLength.UNLIMITED); Document doc = new Document(); doc.Add(new Field("PROD_ID", "", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); doc.Add(new Field("Stores", "", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); for (int i = 1; i &lt;= 10; i++) { doc.GetField("PROD_ID").SetValue(Guid.NewGuid().ToString()); doc.GetField("Stores").SetValue("a075,a073,no2" + i.ToString()); iw.AddDocument(doc); } iw.Optimize(); iw.Commit(); iw.Close(); } private void Search(string KeyWord) { IndexSearcher search = new IndexSearcher(dir, true); QueryParser qp = new QueryParser(Version.LUCENE_30, "Stores", new StandardAnalyzer(Version.LUCENE_30)); Query query = qp.Parse(KeyWord); var hits = search.Search(query, null, search.MaxDoc).ScoreDocs; foreach (var res in hits) { Response.Write(string.Format("PROD_ID:{0} / Stores{1}" , search.Doc(res.Doc).Get("PROD_ID").ToString() , search.Doc(res.Doc).Get("Stores").ToString() + "&lt;BR&gt;")); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload