tags:

views:

658

answers:

1

Hi,

I have a problem with Solr and Faceting and wondering if anyone knows of the fix. I have a work around for it at the minute, however i really want to work out why my query isn't working.

Here is my Schema, simplified to make it easier to follow:

<fields>
    <field name="uniqueid" type="string" indexed="true" required="true"/>
    <!-- Indexed and Stored Field --->
    <field name="recordtype" type="text" indexed="true" stored="true"/>
    <!-- Facet Version of fields -->
    <field name="frecordtype" type="string" indexed="true" stored="false"/>
</fields>

<!-- Copy fields for facet searches -->
<copyField source="recordtype" dest="frecordtype"/>

As you can see I have a case insensitive field called recordtype and it's copied to a case sensitive field frecordtype which does not tokenize the text. This is because solr returns the indexed value rather than the stored value in the faceting results.

When i try the following query:

http://localhost:8080
/solr
/select
?version=2.2
&facet.field=%7b!ex%3dfrecordtype%7dfrecordtype
&facet=on
&fq=%7b!tag%3dfrecordtype%7dfrecordtype%3aLarge%20Record
&f1=*%2cscore
&rows=20
&start=0
&qt=standard
&q=text%3a%25

I don't get any results, however the facteting still shows there is 1 record.

<result name="response" numFound="0" start="0" /> 
 <lst name="facet_counts">
  <lst name="facet_queries" /> 
 <lst name="facet_fields">
 <lst name="frecordtype">
  <int name="Large Record">1</int> 
  <int name="Small Record">12</int> 
  <int name="Other">1</int> 
  </lst>
  </lst>
  <lst name="facet_dates" /> 
  </lst>

However if i change the fitler query (line 7 only) to be on the "recordtype" insted of frecordtype:

http://localhost:8080
/solr
/select
?version=2.2
&facet.field=%7b!ex%3dfrecordtype%7dfrecordtype
&facet=on
&fq=%7b!tag%3dfrecordtype%7drecordtype%3aLarge%20Record
&f1=*%2cscore
&rows=20
&start=0
&qt=standard
&q=text%3a%25

I get the 1 result back that i want.

<result name="response" numFound="1" start="0" /> 
 <lst name="facet_counts">
  <lst name="facet_queries" /> 
 <lst name="facet_fields">
 <lst name="frecordtype">
  <int name="Large Record">1</int> 
  <int name="Small Record">12</int> 
  <int name="Other">1</int> 
  </lst>
  </lst>
  <lst name="facet_dates" /> 
  </lst>

So my question is, is there something i need to do in order to get the first version of the query to return the results i want? Perhaps it's something to do with URL Encoding or something? Any hints from some solr guru's or otherwise would be very grateful.

NOTE: This isn't necessary a faceting question as the faceting is actually working. It's more a query question in that I can't perform a query on a "string" field, even though the case and spacing is exactly the same as the indexed version.

EDIT: For more information on faceting you can check out these blog post's on it:

Thanks

Dave

+4  A: 

You need quotes around the values

E.g.

frecordtype:"Large Record"

works

frecordtype:Large Record

This will search for Large in the frecordtype, which will bring back nothing.. then Record across the default field in solr.

CraftyFella