Re: Using lucene queries to search StringFields

2015-06-21 Thread Jack Krupansky
Unlike Solr, which customizes the query parser to do field-specific analysis, and only analyzes tokenized fields, not string fields, the Lucene query parser will unconditionally analyze every query term for every field using the single specified analyzer, which is the white space analyzer in this c

Re: Using lucene queries to search StringFields

2015-06-21 Thread Gimantha Bandara
@Sheng I am using StandardAnalyzer @Ahmet I know using the query object will simply work. But I hae a requirement where the user insert the whole String and i want to return the doc which exactly match the given text On Fri, Jun 19, 2015 at 9:23 PM, Sheng wrote: > 1. What is the analyzer are yo

Re: Using lucene queries to search StringFields

2015-06-19 Thread Sheng
1. What is the analyzer are you using for indexing ? 2. you cannot fuzzy match field name - that for sure will throw exception 3. I would start from a simple, deterministic query object to rule out all unlikely possibilities first before resorting to parser to generate that for you. On Fri, Jun 1

Re: Using lucene queries to search StringFields

2015-06-19 Thread Ahmet Arslan
Hi, Why don't you create your query with API? Term term = new Term("B", "1 2"); Query query = new TermQuery(term); Ahmet On Friday, June 19, 2015 9:31 AM, Gimantha Bandara wrote: Correction.. second time I used the following code to test. Then I got the above IllegalStateException issue. w

Re: Using lucene queries to search StringFields

2015-06-18 Thread Gimantha Bandara
Correction.. second time I used the following code to test. Then I got the above IllegalStateException issue. w = new QueryParser(null, new WhitespaceAnalyzer()).parse("*B:\"1 2\"*"); not the below one. w = new QueryParser(null, new WhitespaceAnalyzer()).parse("*\**"B:1 2\"*"); Can someone poi

Using lucene queries to search StringFields

2015-06-18 Thread Gimantha Bandara
Hi all, I have created lucene documents like below. Document doc = new Document(); doc.add(new TextField("A", "1", Field.Store.YES)); doc.add(new StringField("B", "1 2 3", Field.Store.NO)); doc.add(new TextField("Publish Date", "2010", Field.Store.NO)); indexWriter.addDocument(doc); doc = new Do