views:

35

answers:

1

I have a String field where I store two-word area names. Ex: New York

Thing is, whenever I try to query that field (area:New York) no results come up, even though it is stored exactly as New York.

Why is this?

The results DO come up if I search like this: area:"New York" but they wont come up if searching like this: area:New.

Any ideas?

Here is the field-definition in the schema.xml file:

  <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
  <field name="area" type="string" indexed="true" stored="true" omitNorms="true"/>

If you need more input let me know!

Thanks

UPDATE

   $fq.=" + area:$state";

I am sending this, and Solr receives this as the variable inside state (New York)...

How can I rewrite this so it sends the variable as "New York" (with double quotes)...?

+1  A: 

Could be a conflict with the reserved keyword New have you tried to retrieve similar results using a different two-word area, such as Las Vegas?

Also, if the area field is expecting a String to always use quotes around your variables.

EDIT:

I do not have any experience using SOLR but assuming area:$state holds New York, I would try inserting the quotes into my code, like so:

$fq.=" + area:\"$state\" ";

It might not be correct, but it could help point you in the right direction.

Anthony Forloney
could you tell me how I should send this variable WITH the double-quotes, check my update for details!
Camran
It's now correct, I will post a new Q about the quotes.. thanks
Camran
I wasn't sure where the value of `New York` was being held, could have been `area:$state` or just `$state` itself, but I hope it helped.
Anthony Forloney