user188962
user188962

Reputation:

Need help with small Solr problem

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)...?

Upvotes: 0

Views: 83

Answers (1)

Anthony Forloney
Anthony Forloney

Reputation: 91816

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.

Upvotes: 1

Related Questions