Re: Limit number of characters returned
--- On Fri, 12/3/10, Mark static.void@gmail.com wrote: From: Mark static.void@gmail.com Subject: Limit number of characters returned To: solr-user@lucene.apache.org Date: Friday, December 3, 2010, 5:39 AM Is there way to limit the number of characters returned from a stored field? For example: Say I have a document (~2K words) and I search for a word that's somewhere in the middle. I would like the document to match the search query but the stored field should only return the first 200 characters of the document. Is there anyway to accomplish this that doesn't involve two fields? I don't think it is possible out-of-the-box. May be you can hack highlighter to return that first 200 characters in highlighting response. Or a custom response writer can do that. But if you will be always returning first 200 characters of documents, I think creating additional field with indexed=false stored=true will be more efficient. And you can make your original field indexed=true stored=false, your index size will be diminished. copyField source=text dest=textShort maxChars=200/
Re: Limit number of characters returned
Correct me if I am wrong but I would like to return highlighted excerpts from the document so I would still need to index and store the whole document right (ie.. highlighting only works on stored fields)? On 12/3/10 3:51 AM, Ahmet Arslan wrote: --- On Fri, 12/3/10, Markstatic.void@gmail.com wrote: From: Markstatic.void@gmail.com Subject: Limit number of characters returned To: solr-user@lucene.apache.org Date: Friday, December 3, 2010, 5:39 AM Is there way to limit the number of characters returned from a stored field? For example: Say I have a document (~2K words) and I search for a word that's somewhere in the middle. I would like the document to match the search query but the stored field should only return the first 200 characters of the document. Is there anyway to accomplish this that doesn't involve two fields? I don't think it is possible out-of-the-box. May be you can hack highlighter to return that first 200 characters in highlighting response. Or a custom response writer can do that. But if you will be always returning first 200 characters of documents, I think creating additional field with indexed=false stored=true will be more efficient. And you can make your original field indexed=true stored=false, your index size will be diminished. copyField source=text dest=textShort maxChars=200/
Re: Limit number of characters returned
Yep, you're correct. CopyField is probably your simplest option here as Ahmet suggested. A more complex solution would be your own response writer, but unless and until you index gets cumbersome, I'd avoid that. Plus, storing the copied contents only shouldn't impact search much, since this doesn't add any terms... Best Erick On Fri, Dec 3, 2010 at 10:32 AM, Mark static.void@gmail.com wrote: Correct me if I am wrong but I would like to return highlighted excerpts from the document so I would still need to index and store the whole document right (ie.. highlighting only works on stored fields)? On 12/3/10 3:51 AM, Ahmet Arslan wrote: --- On Fri, 12/3/10, Markstatic.void@gmail.com wrote: From: Markstatic.void@gmail.com Subject: Limit number of characters returned To: solr-user@lucene.apache.org Date: Friday, December 3, 2010, 5:39 AM Is there way to limit the number of characters returned from a stored field? For example: Say I have a document (~2K words) and I search for a word that's somewhere in the middle. I would like the document to match the search query but the stored field should only return the first 200 characters of the document. Is there anyway to accomplish this that doesn't involve two fields? I don't think it is possible out-of-the-box. May be you can hack highlighter to return that first 200 characters in highlighting response. Or a custom response writer can do that. But if you will be always returning first 200 characters of documents, I think creating additional field with indexed=false stored=true will be more efficient. And you can make your original field indexed=true stored=false, your index size will be diminished. copyField source=text dest=textShort maxChars=200/
Re: Limit number of characters returned
Thanks for the response. Couldn't I just use the highlighter and configure it to use the alternative field to return the first 200 characters? In cases where there is a highlighter match I would prefer to show the excerpts anyway. http://wiki.apache.org/solr/HighlightingParameters#hl.alternateField http://wiki.apache.org/solr/HighlightingParameters#hl.maxAlternateFieldLength Is this something wrong with this method? On 12/3/10 8:03 AM, Erick Erickson wrote: Yep, you're correct. CopyField is probably your simplest option here as Ahmet suggested. A more complex solution would be your own response writer, but unless and until you index gets cumbersome, I'd avoid that. Plus, storing the copied contents only shouldn't impact search much, since this doesn't add any terms... Best Erick On Fri, Dec 3, 2010 at 10:32 AM, Markstatic.void@gmail.com wrote: Correct me if I am wrong but I would like to return highlighted excerpts from the document so I would still need to index and store the whole document right (ie.. highlighting only works on stored fields)? On 12/3/10 3:51 AM, Ahmet Arslan wrote: --- On Fri, 12/3/10, Markstatic.void@gmail.com wrote: From: Markstatic.void@gmail.com Subject: Limit number of characters returned To: solr-user@lucene.apache.org Date: Friday, December 3, 2010, 5:39 AM Is there way to limit the number of characters returned from a stored field? For example: Say I have a document (~2K words) and I search for a word that's somewhere in the middle. I would like the document to match the search query but the stored field should only return the first 200 characters of the document. Is there anyway to accomplish this that doesn't involve two fields? I don't think it is possible out-of-the-box. May be you can hack highlighter to return that first 200 characters in highlighting response. Or a custom response writer can do that. But if you will be always returning first 200 characters of documents, I think creating additional field with indexed=false stored=true will be more efficient. And you can make your original field indexed=true stored=false, your index size will be diminished. copyField source=text dest=textShort maxChars=200/
Re: Limit number of characters returned
Couldn't I just use the highlighter and configure it to use the alternative field to return the first 200 characters? In cases where there is a highlighter match I would prefer to show the excerpts anyway. http://wiki.apache.org/solr/HighlightingParameters#hl.alternateField http://wiki.apache.org/solr/HighlightingParameters#hl.maxAlternateFieldLength Is this something wrong with this method? No, you can do that. It is perfectly fine.
Limit number of characters returned
Is there way to limit the number of characters returned from a stored field? For example: Say I have a document (~2K words) and I search for a word that's somewhere in the middle. I would like the document to match the search query but the stored field should only return the first 200 characters of the document. Is there anyway to accomplish this that doesn't involve two fields? Thanks