Well, PerFieldAnalyzerWrapper is just a bunch of Analyzers,independent of queries. See the API, but in general PerFieldAnalyzerWrapper perf = new PerFieldAnalyzerWrapper("default", new StandardAnalyzer());
perf.add("untokenized", new WhitespaceAnalyzer()); perf.add("tokenized", new SnowballAnalyzer()); etc... Some time later... QueryParser qp = new QueryParser("defaultfield", perf); Query q = qp.parse("tokenized:value1 +tokenized:vaue2) (+untokenized:value3 + untokenized:value4)"); But you have to get from your user input to the field:value form and that's what your application has to do. Presumably your application has some way of getting the query from the user in such a fashion that you can map particular terms to particular fields. If you don't, you have a problem that Lucene can't help you with <G>.. Best Erick On Wed, Mar 11, 2009 at 1:22 AM, rokham <somebodyik...@gmail.com> wrote: > > Thanks a bunch for you very prompt reply. I looked into the > PerFieldAnalyzerWrapper class and I understand how you can add a specific > analyzer for each field. My question is how does this link to the query > that's sent to me. > > If I'm given a query as follows: > (+tokenized:value1 +tokenized:vaue2) (+untokenized:value3 + > untokenized:value4) > > can you please give me a seudo code/code example where I would search > Lucene's index based on the given fields and my desired analyzer for each > field? I'm not clear on how I can go about building a > PerFieldAnalyzerWrapper object without having to parse the query and take > out the fields and assign their specific analyzer to them. > > Rokham > > > > Erick Erickson wrote: > > > > PerFieldAnalyzerWrapper is your friend, assuming that you have separate > > fields, some tokenized and some not. If you *don't* have separate > > fields, then we need more details of what you hope to accomplish... > > > > something like > > > > (+tokenized:value1 +tokenized:vaue2) (+untokenized:value3 + > > untokenized:value4) > > > > should do the trick, where you've constructed a PerFieldAnalyzerWrapper > > with a tokenizing analyzer for field "tokenized" and a non-tokenizing > > analyzer > > for field "untokenized". > > > > Best > > Erick > > > > On Mon, Mar 9, 2009 at 11:01 AM, rokham <somebodyik...@gmail.com> wrote: > > > >> > >> Hi, > >> > >> I've been trying to find a way which allows executing a query that > >> contains > >> both Tokenized and Untokenized fields on Lucene's index, without having > >> to > >> parse the query. I've been able to execute a query which only uses > >> Tokenized > >> fields as follows: > >> > >> QueryParser queryParser = new QueryParser( DEFAULT_FIELD, analyzer); > >> Query query = queryParser.parse(queryString); > >> Hits hits = indexSearcher.search(query); > >> > >> This works fine for Tokenized fields but I'm not sure how to execute a > >> query > >> ("queryString") which contains both tokenized and untokenized fields. > >> > >> Any suggestion is very much appreciated. > >> > >> Rokham > >> -- > >> View this message in context: > >> > http://www.nabble.com/How-to-search-both-Tokenized-and-Untokenized-fields-tp22413438p22413438.html > >> Sent from the Lucene - Java Users mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > >> For additional commands, e-mail: java-user-h...@lucene.apache.org > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/How-to-search-both-Tokenized-and-Untokenized-fields-tp22413438p22449012.html > Sent from the Lucene - Java Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >