简体   繁体   English

是否可以查询多个AWS Cloudsearch字段以获取相同的值而无需重复?

[英]Is it possible to query multiple AWS Cloudsearch fields for the same value without repeating?

Using AWS Cloudsearch, I need to query 2 separate fields for the same value using a structured (compound) query eg 使用AWS Cloudsearch,我需要使用结构化(复合)查询来查询2个单独的字段以获取相同的值,例如

(and (or name:'john smith') (or curr_addr:'123 someplace' other_addr:'123 someplace'))

This query works, but I'm wondering if it's necessary to repeat the value for each field that I want to search against. 该查询有效,但我想知道是否有必要针对我要搜索的每个字段重复该值。 Is there some way to specify the value only once eg curr_addr+other_addr:'123 someplace' 有没有办法只指定一次值,例如curr_addr+other_addr:'123 someplace'

That is the correct way to structure your compound query. 这是构造复合查询的正确方法。 From the AWS documentation, you'll see that they structure their example query the same way: 从AWS文档中,您将看到它们以相同的方式构造示例查询:

(and title:'star' (or actors:'Harrison Ford' actors:'William Shatner')(not actors:'Zachary Quinto'))

From Constructing Compound Queries 构造复合查询

You may be able to get around this by listing the more repetitive fields in the query options ( q.options ), and then specify the field for the rest of the fields. 通过在查询选项( q.options )中列出更多重复字段,然后为其余字段指定该字段,您也许可以解决此问题。 The fields list is sort of a fallback for when you don't specify which field you are searching in a compound query. 当您不指定要在复合查询中搜索的字段时, fields列表有点后退。 So if you list the address fields there, and then only specify the name field in your query, you may get close to the behavior you're looking for. 因此,如果您在此处列出地址字段,然后仅在查询中指定name字段,则可能会接近所要查找的行为。

Query options 查询选项

q.options={fields: ['curr_addr','other_addr']}

Query 询问

(and (or name:'john smith') (or '123 someplace'))

But this approach would only work for one set of repetitive fields, so it's not a silver bullet by any means. 但是这种方法仅适用于一组重复字段,因此无论如何它都不是灵丹妙药。

From Search API Reference (see q.options => fields ) 来自Search API参考 (请参阅q.options => fields

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM