Can we do a lucene query without the key and just providing the value? For ex: Lets have index is on created on following two properties, city and country Now, can i search, "*:query" , without specifying any of the properties name.
Thanks, Abdul
Can we do a lucene query without the key and just providing the value? For ex: Lets have index is on created on following two properties, city and country Now, can i search, "*:query" , without specifying any of the properties name.
Thanks, Abdul
您可以配置一个默认字段,但如果您想使用单个查询词搜索两个(或全部)数据,您可以创建一个新字段进行搜索,并将所有用于搜索的数据添加到该字段。所以现在你要添加:
city: mycity
country: mycountry
您可以添加另一个字段,将其称为地址或文本,这对您的使用有意义,因此我们有:
city: mycity
country: mycountry
address: mycity mycountry maybe even some other things too
我现在可以搜索城市或国家或两者的“地址”,并按相关性进行良好排序。
您需要确保 'city' 和 'country' 并已存储 (Field.Store.YES),以便稍后获取它们。“地址”仅用于搜索,因此请确保已对其进行索引(Field.Index.ANALYZED),并且很可能未存储(Field.Store.NO)。是否要索引城市和国家取决于您,但如果您只想搜索一个词作为国家,这可能不是一个坏主意。