RE: Returning one result
Ok thanks, but still I can't use the Simple analyzer since it won't even index that whole thing. I 'll give TermQuery a try. Thanks. -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Thursday, December 04, 2003 6:18 PM To: Lucene Users List Subject: Re: Returning one result You really should use a TermQuery in this case anyway, rather than using QueryParser. You wouldn't have to worry about the analyzer at that point anyway (and I assume you're using Field.Keyword during indexing). Erik On Thursday, December 4, 2003, at 05:01 PM, Pleasant, Tracy wrote: Ok I realized teh Simple Analyzer does not index numbers, so I switched back to Standard. -Original Message- From: Pleasant, Tracy Sent: Thursday, December 04, 2003 4:53 PM To: Lucene Users List Subject: Returning one result I am indexing a group of items and one field , id, is unique. When the user clicks on a results I want just that one result to show. I index and search using SimpleAnalyzer. Query query_es = QueryParser.parse(query, id, new SimpleAnalyzer()); It should return only one result but returns 200. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Returning one result
Maybe I should have been more clear. static Field Keyword(String name, String value) Constructs a String-valued Field that is not tokenized, but is indexed and stored. I need to have it tokenized because people will search for that also and it needs to be searchable. Should I have two fields - one as a keyword and one as text? How would I do that when I want to return search results.. Right now, in the results page it will have something like a href=display_record.jsp?id=AR334Record AR334/a Then in display_record.jsp: Searcher searcher = new IndexSearcher(index); String term = request.getParameter(id); Query query = QueryParser.parse(term, id, new StandardAnalyzer()); Hits hits = searcher.search(query); Would it have to be something like: TermQuery query = ??? or Query query = QueryParser.Term(id); ? ? ? -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Thursday, December 04, 2003 6:18 PM To: Lucene Users List Subject: Re: Returning one result You really should use a TermQuery in this case anyway, rather than using QueryParser. You wouldn't have to worry about the analyzer at that point anyway (and I assume you're using Field.Keyword during indexing). Erik On Thursday, December 4, 2003, at 05:01 PM, Pleasant, Tracy wrote: Ok I realized teh Simple Analyzer does not index numbers, so I switched back to Standard. -Original Message- From: Pleasant, Tracy Sent: Thursday, December 04, 2003 4:53 PM To: Lucene Users List Subject: Returning one result I am indexing a group of items and one field , id, is unique. When the user clicks on a results I want just that one result to show. I index and search using SimpleAnalyzer. Query query_es = QueryParser.parse(query, id, new SimpleAnalyzer()); It should return only one result but returns 200. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning one result
On Friday, December 5, 2003, at 10:31 AM, Pleasant, Tracy wrote: Ok thanks, but still I can't use the Simple analyzer since it won't even index that whole thing. I 'll give TermQuery a try. Thanks. Yes, certainly the analyzer is important for analyzed fields, but it is not used for Field.Keyword. Please provide more details on the issue you encountered using Field.Keyword. -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Thursday, December 04, 2003 6:18 PM To: Lucene Users List Subject: Re: Returning one result You really should use a TermQuery in this case anyway, rather than using QueryParser. You wouldn't have to worry about the analyzer at that point anyway (and I assume you're using Field.Keyword during indexing). Erik On Thursday, December 4, 2003, at 05:01 PM, Pleasant, Tracy wrote: Ok I realized teh Simple Analyzer does not index numbers, so I switched back to Standard. -Original Message- From: Pleasant, Tracy Sent: Thursday, December 04, 2003 4:53 PM To: Lucene Users List Subject: Returning one result I am indexing a group of items and one field , id, is unique. When the user clicks on a results I want just that one result to show. I index and search using SimpleAnalyzer. Query query_es = QueryParser.parse(query, id, new SimpleAnalyzer()); It should return only one result but returns 200. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Returning one result
What I meant is. Say ID is Ar3453 .. well the user may want to search for Ar3453, so in order for it to be searchable then it would have to be indexed and not a keyword. So after using TermQuery query = new TermQuery(new Term(id, term)); How would I return the other fields in the document? For instance to display a record it would get the record with the id # and then display the title, contents, etc. -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 11:32 AM To: Lucene Users List Subject: Re: Returning one result On Friday, December 5, 2003, at 10:41 AM, Pleasant, Tracy wrote: Maybe I should have been more clear. static Field Keyword(String name, String value) Constructs a String-valued Field that is not tokenized, but is indexed and stored. I need to have it tokenized because people will search for that also and it needs to be searchable. Search for *what* also? Tokenized means that it is broken into pieces which will be separate terms. For example: see spot is tokenized into see and spot, and searching for either of those terms will match. Just try it and see, please! :) Should I have two fields - one as a keyword and one as text? Depends on what you're doing... but an id field to me indicates Field.Keyword to me, only. How would I do that when I want to return search results.. Searcher searcher = new IndexSearcher(index); String term = request.getParameter(id); Query query = QueryParser.parse(term, id, new StandardAnalyzer()); Hits hits = searcher.search(query); Would it have to be something like: TermQuery query = ??? Yes. TermQuery query = new TermQuery(new Term(id, term)); Use searcher.search exactly as you did before. Just don't use QueryParser to construct a query. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Returning one result
Also what I am indexing is not a bunch of separate documents - or then it would be easy to simply have a field called url and then the link would go directly do that document. However, there is a text URL with many records During indexing, a function parses each record and puts each into a document with appropriate fields. When I go to display a particular Document (Lucene Document) I just query the index for that unique ID rather than go through and parse through the URL with all the records. Wouldn't querying the index for that unique ID be better than going through that entire page and parsing through it - there is more room for error that way. It's a long story why there isn't a database but it can't be done (don't ask ... long story). -Original Message- From: Pleasant, Tracy Sent: Friday, December 05, 2003 1:25 PM To: Lucene Users List Subject: RE: Returning one result What I meant is. Say ID is Ar3453 .. well the user may want to search for Ar3453, so in order for it to be searchable then it would have to be indexed and not a keyword. So after using TermQuery query = new TermQuery(new Term(id, term)); How would I return the other fields in the document? For instance to display a record it would get the record with the id # and then display the title, contents, etc. -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 11:32 AM To: Lucene Users List Subject: Re: Returning one result On Friday, December 5, 2003, at 10:41 AM, Pleasant, Tracy wrote: Maybe I should have been more clear. static Field Keyword(String name, String value) Constructs a String-valued Field that is not tokenized, but is indexed and stored. I need to have it tokenized because people will search for that also and it needs to be searchable. Search for *what* also? Tokenized means that it is broken into pieces which will be separate terms. For example: see spot is tokenized into see and spot, and searching for either of those terms will match. Just try it and see, please! :) Should I have two fields - one as a keyword and one as text? Depends on what you're doing... but an id field to me indicates Field.Keyword to me, only. How would I do that when I want to return search results.. Searcher searcher = new IndexSearcher(index); String term = request.getParameter(id); Query query = QueryParser.parse(term, id, new StandardAnalyzer()); Hits hits = searcher.search(query); Would it have to be something like: TermQuery query = ??? Yes. TermQuery query = new TermQuery(new Term(id, term)); Use searcher.search exactly as you did before. Just don't use QueryParser to construct a query. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning one result
On Friday, December 5, 2003, at 01:25 PM, Pleasant, Tracy wrote: Say ID is Ar3453 .. well the user may want to search for Ar3453, so in order for it to be searchable then it would have to be indexed and not a keyword. *arg* - we're having a serious communication issue here. My advice to you is to actually write some simple tests (test-driven learning using JUnit is a wonderful way to experiement with Lucene, especially thanks to the RAMDirectory). Please refer to my articles at java.net as well as the other great Lucene articles out there. Let me try again a Field.Keyword *IS* indexed! Even Lucene's javadocs say this for this method: /** Constructs a String-valued Field that is not tokenized, but is indexed and stored. Useful for non-text fields, e.g. date or url. */ [I added the emphasis there] So after using TermQuery query = new TermQuery(new Term(id, term)); How would I return the other fields in the document? For instance to display a record it would get the record with the id # and then display the title, contents, etc. Umm you'd use *exactly* the same way as if you had used QueryParser. QueryParser would create a TermQuery for you, in fact, except it would analyze your text first, which is what you want to avoid, right? Hits.doc(n) gives you back a Document. And then Document.get(fieldName) gives you back the fields (as long as you stored them in the index too). Again, please attempt some of these things in code. It is a trivial matter to index and search using RAMDirectory and experiment with TermQuery, QueryParser, Analyzers, etc. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning one result
On Fri, Dec 05, 2003 at 01:25:23PM -0500, Pleasant, Tracy wrote: What I meant is. Say ID is Ar3453 .. well the user may want to search for Ar3453, so in order for it to be searchable then it would have to be indexed and not a keyword. No. You should store it as a keyword. From the javadocs: Keyword(String name, String value) Constructs a String-valued Field that is not tokenized, but is indexed and stored. So after using TermQuery query = new TermQuery(new Term(id, term)); How would I return the other fields in the document? For instance to display a record it would get the record with the id # and then display the title, contents, etc. -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 11:32 AM To: Lucene Users List Subject: Re: Returning one result On Friday, December 5, 2003, at 10:41 AM, Pleasant, Tracy wrote: Maybe I should have been more clear. static Field Keyword(String name, String value) Constructs a String-valued Field that is not tokenized, but is indexed and stored. I need to have it tokenized because people will search for that also and it needs to be searchable. Search for *what* also? Tokenized means that it is broken into pieces which will be separate terms. For example: see spot is tokenized into see and spot, and searching for either of those terms will match. Just try it and see, please! :) Should I have two fields - one as a keyword and one as text? Depends on what you're doing... but an id field to me indicates Field.Keyword to me, only. How would I do that when I want to return search results.. Searcher searcher = new IndexSearcher(index); String term = request.getParameter(id); Query query = QueryParser.parse(term, id, new StandardAnalyzer()); Hits hits = searcher.search(query); Would it have to be something like: TermQuery query = ??? Yes. TermQuery query = new TermQuery(new Term(id, term)); Use searcher.search exactly as you did before. Just don't use QueryParser to construct a query. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Returning one result
Maybe we are having some communication issues. At any rate, I did index it as a KEYWORD and when displaying used the TermQuery. The only problem with this though is by storing the ID (i.e. AR345) as a Keyword, if I search for AR345 no results are returned when I use the MultiFieldQueryParser . *sigh* *arg* -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 2:13 PM To: Lucene Users List Subject: Re: Returning one result On Friday, December 5, 2003, at 01:25 PM, Pleasant, Tracy wrote: Say ID is Ar3453 .. well the user may want to search for Ar3453, so in order for it to be searchable then it would have to be indexed and not a keyword. *arg* - we're having a serious communication issue here. My advice to you is to actually write some simple tests (test-driven learning using JUnit is a wonderful way to experiement with Lucene, especially thanks to the RAMDirectory). Please refer to my articles at java.net as well as the other great Lucene articles out there. Let me try again a Field.Keyword *IS* indexed! Even Lucene's javadocs say this for this method: /** Constructs a String-valued Field that is not tokenized, but is indexed and stored. Useful for non-text fields, e.g. date or url. */ [I added the emphasis there] So after using TermQuery query = new TermQuery(new Term(id, term)); How would I return the other fields in the document? For instance to display a record it would get the record with the id # and then display the title, contents, etc. Umm you'd use *exactly* the same way as if you had used QueryParser. QueryParser would create a TermQuery for you, in fact, except it would analyze your text first, which is what you want to avoid, right? Hits.doc(n) gives you back a Document. And then Document.get(fieldName) gives you back the fields (as long as you stored them in the index too). Again, please attempt some of these things in code. It is a trivial matter to index and search using RAMDirectory and experiment with TermQuery, QueryParser, Analyzers, etc. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Returning one result
Thanks, but using it as a Keyword, it will not get returned with my search results when I use MultiFieldQueryParser. If I could I would use just parse(query) but that is not a static method, only parse(query,field,analyzer) is... So when I do that and use an analyzer, the keyword field isn't searched. -Original Message- From: Dror Matalon [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 2:14 PM To: Lucene Users List Subject: Re: Returning one result On Fri, Dec 05, 2003 at 01:25:23PM -0500, Pleasant, Tracy wrote: What I meant is. Say ID is Ar3453 .. well the user may want to search for Ar3453, so in order for it to be searchable then it would have to be indexed and not a keyword. No. You should store it as a keyword. From the javadocs: Keyword(String name, String value) Constructs a String-valued Field that is not tokenized, but is indexed and stored. So after using TermQuery query = new TermQuery(new Term(id, term)); How would I return the other fields in the document? For instance to display a record it would get the record with the id # and then display the title, contents, etc. -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 11:32 AM To: Lucene Users List Subject: Re: Returning one result On Friday, December 5, 2003, at 10:41 AM, Pleasant, Tracy wrote: Maybe I should have been more clear. static Field Keyword(String name, String value) Constructs a String-valued Field that is not tokenized, but is indexed and stored. I need to have it tokenized because people will search for that also and it needs to be searchable. Search for *what* also? Tokenized means that it is broken into pieces which will be separate terms. For example: see spot is tokenized into see and spot, and searching for either of those terms will match. Just try it and see, please! :) Should I have two fields - one as a keyword and one as text? Depends on what you're doing... but an id field to me indicates Field.Keyword to me, only. How would I do that when I want to return search results.. Searcher searcher = new IndexSearcher(index); String term = request.getParameter(id); Query query = QueryParser.parse(term, id, new StandardAnalyzer()); Hits hits = searcher.search(query); Would it have to be something like: TermQuery query = ??? Yes. TermQuery query = new TermQuery(new Term(id, term)); Use searcher.search exactly as you did before. Just don't use QueryParser to construct a query. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning one result
On Fri, Dec 05, 2003 at 03:14:08PM -0500, Pleasant, Tracy wrote: What do you mean 'add' in MultiFieldQueryParser? I am using all the fields Sorry, that was wrong. What I meant to say is are you adding the field to the array of fields that need to be searched? You need to use a MultiFieldQueryParser and pass it the array of fields that you want searched. Dror When I index it does add (Field.Keyword(..,..)) But I don't want the user to have to type ID:ID NUMBER It would be nice to just type ID Number. On your site if you just put: 11183 in the search box there are no results. well, right now I'll just do it as text and query that field for the id # to display the document. It can't hurt, right? :) Unless the Keyword is a better way -Original Message- From: Dror Matalon [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 3:06 PM To: Lucene Users List Subject: Re: Returning one result On Fri, Dec 05, 2003 at 02:45:34PM -0500, Pleasant, Tracy wrote: Maybe we are having some communication issues. At any rate, I did index it as a KEYWORD and when displaying used the TermQuery. The only problem with this though is by storing the ID (i.e. AR345) as a Keyword, if I search for AR345 no results are returned when I use the MultiFieldQueryParser . *sigh* *arg* OK. Go to http://www.fastbuzz.com/search/index.jsp and type lucene without the quotes and hit search. You get results from different channels/rss feeds. Now type lucene channel:11183 without the quotes and hit search. You get results only from Java-Channel. We're inserting the field channel as a keyword, and it does what I understand you want to use AR345. I would guess that in MultiFieldQueryParser you are not doing an add() of the field for AR345 which is why the search fails. Regards, Dror -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 2:13 PM To: Lucene Users List Subject: Re: Returning one result On Friday, December 5, 2003, at 01:25 PM, Pleasant, Tracy wrote: Say ID is Ar3453 .. well the user may want to search for Ar3453, so in order for it to be searchable then it would have to be indexed and not a keyword. *arg* - we're having a serious communication issue here. My advice to you is to actually write some simple tests (test-driven learning using JUnit is a wonderful way to experiement with Lucene, especially thanks to the RAMDirectory). Please refer to my articles at java.net as well as the other great Lucene articles out there. Let me try again a Field.Keyword *IS* indexed! Even Lucene's javadocs say this for this method: /** Constructs a String-valued Field that is not tokenized, but is indexed and stored. Useful for non-text fields, e.g. date or url. */ [I added the emphasis there] So after using TermQuery query = new TermQuery(new Term(id, term)); How would I return the other fields in the document? For instance to display a record it would get the record with the id # and then display the title, contents, etc. Umm you'd use *exactly* the same way as if you had used QueryParser. QueryParser would create a TermQuery for you, in fact, except it would analyze your text first, which is what you want to avoid, right? Hits.doc(n) gives you back a Document. And then Document.get(fieldName) gives you back the fields (as long as you stored them in the index too). Again, please attempt some of these things in code. It is a trivial matter to index and search using RAMDirectory and experiment with TermQuery, QueryParser, Analyzers, etc. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning one result
Mike, Boy, I said it so badly and yet you understood :-). Dror On Fri, Dec 05, 2003 at 03:31:15PM -0500, Michael Giles wrote: Tracy, I believe what Dror was referring to was the call to MultiFieldQueryParser.parse(). The second argument to that call is a String[] of field names on which to execute the query. If the field that contains AR345 isn't listed in that array, you will not get any results. -Mike At 03:14 PM 12/5/2003, you wrote: What do you mean 'add' in MultiFieldQueryParser? I am using all the fields When I index it does add (Field.Keyword(..,..)) But I don't want the user to have to type ID:ID NUMBER It would be nice to just type ID Number. On your site if you just put: 11183 in the search box there are no results. well, right now I'll just do it as text and query that field for the id # to display the document. It can't hurt, right? :) Unless the Keyword is a better way - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning one result
Then I'm out of ideas. The next thing is for you to post your search code so we can see why it's not searching the field. On Fri, Dec 05, 2003 at 03:34:38PM -0500, Pleasant, Tracy wrote: Yes it is in the list of arrays that I want searched. -Original Message- From: Dror Matalon [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 3:32 PM To: Lucene Users List Subject: Re: Returning one result On Fri, Dec 05, 2003 at 03:14:08PM -0500, Pleasant, Tracy wrote: What do you mean 'add' in MultiFieldQueryParser? I am using all the fields Sorry, that was wrong. What I meant to say is are you adding the field to the array of fields that need to be searched? You need to use a MultiFieldQueryParser and pass it the array of fields that you want searched. Dror When I index it does add (Field.Keyword(..,..)) But I don't want the user to have to type ID:ID NUMBER It would be nice to just type ID Number. On your site if you just put: 11183 in the search box there are no results. well, right now I'll just do it as text and query that field for the id # to display the document. It can't hurt, right? :) Unless the Keyword is a better way -Original Message- From: Dror Matalon [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 3:06 PM To: Lucene Users List Subject: Re: Returning one result On Fri, Dec 05, 2003 at 02:45:34PM -0500, Pleasant, Tracy wrote: Maybe we are having some communication issues. At any rate, I did index it as a KEYWORD and when displaying used the TermQuery. The only problem with this though is by storing the ID (i.e. AR345) as a Keyword, if I search for AR345 no results are returned when I use the MultiFieldQueryParser . *sigh* *arg* OK. Go to http://www.fastbuzz.com/search/index.jsp and type lucene without the quotes and hit search. You get results from different channels/rss feeds. Now type lucene channel:11183 without the quotes and hit search. You get results only from Java-Channel. We're inserting the field channel as a keyword, and it does what I understand you want to use AR345. I would guess that in MultiFieldQueryParser you are not doing an add() of the field for AR345 which is why the search fails. Regards, Dror -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 2:13 PM To: Lucene Users List Subject: Re: Returning one result On Friday, December 5, 2003, at 01:25 PM, Pleasant, Tracy wrote: Say ID is Ar3453 .. well the user may want to search for Ar3453, so in order for it to be searchable then it would have to be indexed and not a keyword. *arg* - we're having a serious communication issue here. My advice to you is to actually write some simple tests (test-driven learning using JUnit is a wonderful way to experiement with Lucene, especially thanks to the RAMDirectory). Please refer to my articles at java.net as well as the other great Lucene articles out there. Let me try again a Field.Keyword *IS* indexed! Even Lucene's javadocs say this for this method: /** Constructs a String-valued Field that is not tokenized, but is indexed and stored. Useful for non-text fields, e.g. date or url. */ [I added the emphasis there] So after using TermQuery query = new TermQuery(new Term(id, term)); How would I return the other fields in the document? For instance to display a record it would get the record with the id # and then display the title, contents, etc. Umm you'd use *exactly* the same way as if you had used QueryParser. QueryParser would create a TermQuery for you, in fact, except it would analyze your text first, which is what you want to avoid, right? Hits.doc(n) gives you back a Document. And then Document.get(fieldName) gives you back the fields (as long as you stored them in the index too). Again, please attempt some of these things in code. It is a trivial matter to index and search using RAMDirectory and experiment with TermQuery, QueryParser, Analyzers, etc. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com - To unsubscribe, e-mail: [EMAIL PROTECTED
Re: Returning one result
On Friday, December 5, 2003, at 04:28 PM, Dror Matalon wrote: Then I'm out of ideas. The next thing is for you to post your search code so we can see why it's not searching the field. Giving up so easily, Dror?! :)) The problem is, when using any type of QueryParser with a Keyword field, you have to then be careful about analysis. My guess is that at query parsing time, that the analyzer is stripping numbers or in some mangling the id. Look back in the e-mail archives for my AnalyzerUtils, run a string containing just a sample id through it using the analyzer you are using in your real code and see what comes out. Again, Tracy, please read the articles at java.net on Lucene - and there is one on QueryParser too. You are definitely having a learning curve situation here and aren't quite in the zone of Lucene understanding yet, that is why folks here are getting frustrated with your questions. We are hanging in there with you though and will get you through this. I'll give you some pointers here - in the latest Lucene 1.3 versions, there is a PerFieldAnalyzerWrapper that might come in handy here - otherwise you might consider using a different analyzer. A good first pass is to experiment with the WhitespaceAnalyzer and be sure to phrase your test queries with the same case you indexed with. I believe you'll find that it will work. If it works then, you will have a very good clue that the analyzer is the problem. At that point, go and read those java.net articles I wrote, especially the first one having to do with analyzers. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning one result
You really should use a TermQuery in this case anyway, rather than using QueryParser. You wouldn't have to worry about the analyzer at that point anyway (and I assume you're using Field.Keyword during indexing). Erik On Thursday, December 4, 2003, at 05:01 PM, Pleasant, Tracy wrote: Ok I realized teh Simple Analyzer does not index numbers, so I switched back to Standard. -Original Message- From: Pleasant, Tracy Sent: Thursday, December 04, 2003 4:53 PM To: Lucene Users List Subject: Returning one result I am indexing a group of items and one field , id, is unique. When the user clicks on a results I want just that one result to show. I index and search using SimpleAnalyzer. Query query_es = QueryParser.parse(query, id, new SimpleAnalyzer()); It should return only one result but returns 200. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]