You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by melkink <me...@gmail.com> on 2007/09/08 00:01:06 UTC

New user question: How to show all stored fields in a result

Hello Solr Folks,

I'm a new solr user and I'm running into a frustrating problem.  I'm sure
it's a simple solution I just don't have the experience with solr to know
the correct way around it.

I currently have approximately 600 documents stored and indexed in solr. 
Each document has some level of associated metadata. I can query the solr
index with no problems but I can't seem to get a full set 	of metadata with
my search results.  For example, if I search on the text of the stored
document all that is sent back is the score and the id of the hit.

Query:  

http://localhost:8983/solr/select?indent=on&version=2.2&q=doctext%3Ashakespeare&start=0&rows=10&fl=*&qt=standard&wt=standard&explainOther=&hl.fl=

Partial Result:

<response>
	<lst name="responseHeader">
		<int name="status">0</int>
		<int name="QTime">1</int>
		<lst name="params">
			<str name="explainOther"/>
			<str name="fl">*</str>
			<str name="indent">on</str>
			<str name="start">0</str>
			<str name="q">doctext:shakespeare</str>
			<str name="hl.fl"/>
			<str name="qt">standard</str>
			<str name="wt">standard</str>
			<str name="version">2.2</str>
			<str name="rows">10</str>
		</lst>
	</lst>
	<result name="response" numFound="470" start="0">
		<doc>
			<str name="id">2eb453aab5101de037ba0747139ebd27</str>
		</doc>
		...
	</result>
</response>

However, If I search the authors_primary field I get the full metadata
listing:

Query:

http://localhost:8983/solr/select?indent=on&version=2.2&q=authors_primary%3A%22Russ%2CJon+R.%22&start=0&rows=10&fl=*%2Cscore&qt=standard&wt=standard&explainOther=&hl.fl=

Result:

<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
 <int name="status">0</int>
 <int name="QTime">0</int>
 <lst name="params">
  <str name="explainOther"/>
  <str name="fl">*,score</str>
  <str name="indent">on</str>
  <str name="start">0</str>
  <str name="q">authors_primary:"Russ,Jon R."</str>
  <str name="hl.fl"/>
  <str name="qt">standard</str>
  <str name="wt">standard</str>
  <str name="version">2.2</str>
  <str name="rows">10</str>
 </lst>
</lst>
<result name="response" numFound="1" start="0" maxScore="6.4764633">
 <doc>
  <float name="score">6.4764633</float>
  <str name="abstract">[Asserts that the "brass" of line 3 of Sonnet 1 is a
metonym for cannon.]</str>
  <str name="accession_number"> </str>
  <str name="author_address"> </str>
  <str name="authors_primary">Russ,Jon R.</str>
  <str name="authors_quaternary">Anonymous </str>
  <str name="authors_quinary">Anonymous </str>
  <str name="authors_secondary">Anonymous</str>
  <str name="authors_tertiary">Anonymous</str>
  <str name="availability"> </str>
  <str name="call_number"> </str>
  <str name="classification"> </str>
  <str name="data_source"> </str>
  <str name="database"> </str>
  <str name="doi"> </str>
  <str name="edition"> </str>
  <str name="id">2eb453aab5101de037ba0747139ebd27</str>
  <str name="identifying_phrase"> </str>
  <str name="issn_isbn">0014-4940</str>
  <str name="issue"> </str>
  <str name="keywords">English literature;1500-1599;Shakespeare,
William;Sonnets</str>
  <str name="language"> </str>
  <str
name="links">http://search.epnet.com/login.aspx?direct=true&amp;db=mzh&amp;an=1972103657</str>
  <str name="notes">Accession Number: 1972103657. Peer Reviewed: Yes.
Publication Type: journal article. Language: English. Update Code: 197201.
Sequence No: 1972-1-3657. INDIVIDUAL WORKS - PLAYS; The Sonnets; Scholarship
and Criticism; Textual and Bibliographical Studies; metonymy</str>
  <str name="original_foreign_title"> </str>
  <str name="other_pages"> </str>
  <str name="periodical_abbrev"> </str>
  <str name="periodical_full">Explicator</str>
  <str name="place_of_publication">Washington, DC</str>
  <str name="pub_date_free_from"> </str>
  <str name="pub_year">1972</str>
  <str name="publisher"> </str>
  <str name="reference_type">Journal</str>
  <str name="retrieved_date"> </str>
  <str name="shortened_title"> </str>
  <str name="start_page">Item 38</str>
  <str name="subfile_database"> </str>
  <str name="title_primary">Shakespeare's Sonnet LXIV</str>
  <str name="title_secondary"> </str>
  <str name="title_tertiary"> </str>
  <str name="user_1"> </str>
  <str name="user_2"> </str>
  <str name="user_3"> </str>
  <str name="user_4"> </str>
  <str name="user_5"> </str>
  <str name="volume">30</str>
 </doc>
</result>
</response>

How do I get the full metadata listing when I do a query on the doctext
field.  I've attached my schema.xml file in case that can help someone
answser my question.

Thank you in advance!

Mike

http://www.nabble.com/file/p12531829/schema.xml schema.xml 

-- 
View this message in context: http://www.nabble.com/New-user-question%3A-How-to-show-all-stored-fields-in-a-result-tf4394773.html#a12531829
Sent from the Solr - User mailing list archive at Nabble.com.


Re: New user question: How to show all stored fields in a result

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Sep 11, 2007, at 5:13 PM, melkink wrote:

>
>
>
> Erik Hatcher wrote:
>>
>>
>> melkink - are you using solr-ruby?  If so, that bug has been fixed in
>> later versions ;)
>>
>> 	Erik
>>
>>
>>
>
> Erik,
>
> Indeed I am!  Thanks for letting me know that there's a new version
> available that fixes this bug.  Like I said I'm a bit of noob when  
> it comes
> to both solr and ruby so it takes me that much longer to figure out  
> where
> things are getting messed up.

It was a subtle bug that had me scratching my head even after I had  
fixed it when I encountered it again in an app using an older version  
of the library.

> Thanks, btw, for the solr-ruby library.  Very cool.

Thanks!   There is a mailing list where we primarily discuss solr- 
ruby: ruby-dev@lucene.apache.org

	Erik


Re: New user question: How to show all stored fields in a result

Posted by melkink <me...@gmail.com>.


Erik Hatcher wrote:
> 
> 
> melkink - are you using solr-ruby?  If so, that bug has been fixed in  
> later versions ;)
> 
> 	Erik
> 
> 
> 

Erik,

Indeed I am!  Thanks for letting me know that there's a new version
available that fixes this bug.  Like I said I'm a bit of noob when it comes
to both solr and ruby so it takes me that much longer to figure out where
things are getting messed up.

Thanks, btw, for the solr-ruby library.  Very cool.

Mike
-- 
View this message in context: http://www.nabble.com/New-user-question%3A-How-to-show-all-stored-fields-in-a-result-tf4394773.html#a12623960
Sent from the Solr - User mailing list archive at Nabble.com.


Re: New user question: How to show all stored fields in a result

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Sep 10, 2007, at 3:07 PM, Mike Klaas wrote:
> On 10-Sep-07, at 11:54 AM, melkink wrote:
>
>>
>> The other change I made (which may or may not have contributed to the
>> solution) was to remove all line breaks from the text being  
>> submitted to the
>> doctext field.  The line breaks were causing solr to interpret the  
>> text as
>> having multiple values and forced me to put a multivalued="true"  
>> attribute
>> in the schema.xml.  Removing the line breaks allowed me to remove  
>> this
>> attribute.
>
> Interesting--I've never seen this behaviour (I definitely store  
> fields with linebreaks in strings).
>
> Are you sure that it isn't your own framework that is generating  
> multiple <field> entries for this input case?

Interestingly the solr-ruby library would create multiple field  
versions before I fixed the issue.  A document like this:

    {:id => 123, :text => "a newline\nin the middle"}

would require "text" to be multiValued.  The reason was because the  
magic under the covers looks at the field value objects and iterates  
over them if they implement the #each method.  String#each returns  
each _line_ - *sigh* (going away in later versions of Ruby, thank  
goodness).

melkink - are you using solr-ruby?  If so, that bug has been fixed in  
later versions ;)

	Erik


Re: New user question: How to show all stored fields in a result

Posted by Mike Klaas <mi...@gmail.com>.
On 10-Sep-07, at 11:54 AM, melkink wrote:

>
> The other change I made (which may or may not have contributed to the
> solution) was to remove all line breaks from the text being  
> submitted to the
> doctext field.  The line breaks were causing solr to interpret the  
> text as
> having multiple values and forced me to put a multivalued="true"  
> attribute
> in the schema.xml.  Removing the line breaks allowed me to remove this
> attribute.

Interesting--I've never seen this behaviour (I definitely store  
fields with linebreaks in strings).

Are you sure that it isn't your own framework that is generating  
multiple <field> entries for this input case?

glad to hear you figured it out,
-Mike

Re: New user question: How to show all stored fields in a result

Posted by melkink <me...@gmail.com>.
Well, I figured out my problem.  User error of course ;-)

I was processing documents in two separate steps.  The first step added the
id and the doctext fields.  The second step did an update to add the
metadata.  I didn't realize that an update command replaced the whole
document rather than just the pieces you specify.  I altered the process so
that everything was added in one step and now things are working much
better.

The other change I made (which may or may not have contributed to the
solution) was to remove all line breaks from the text being submitted to the
doctext field.  The line breaks were causing solr to interpret the text as
having multiple values and forced me to put a multivalued="true" attribute
in the schema.xml.  Removing the line breaks allowed me to remove this
attribute.

*Breathes giant sigh of relief*
-- 
View this message in context: http://www.nabble.com/New-user-question%3A-How-to-show-all-stored-fields-in-a-result-tf4394773.html#a12599438
Sent from the Solr - User mailing list archive at Nabble.com.