开发者

Need help with small Solr problem

开发者 https://www.devze.com 2022-12-18 13:12 出处:网络
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.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消