q与fq上查询的区别
responseHeader: { ElapsedTime: 312, TotalTime: 840, SolrTime: 1140, status: 0, QTime: 240, params: { facet: "true", sort: "SALEQTY desc, IS_BOTTOM asc,score desc, SM_SOLDQTY desc ,IS_MAIN_SKU desc,SM_SOLDQTY desc,SM_SEQ desc", group.ngroups: "true", facet.mincount: "1", facet.limit: "500", group.limit: "50", wt: "javabin", f.IS_MALL.group.facet: "true", version: "2", defType: "edismax", rows: "540", bq: "CP_SEQ:(CC201751^79.80000000000001 OR CC202069^9.47 OR CC200853^4.72 OR CC200000^3.9800000000000004 OR CC201753^0.22999999999999998) OR IS_PROMOTION:(1^1)", fl: "SM_SEQ,SM_TITLE,SM_PRICE,SM_PIC,SALEQTY,IT_COLOR_SEQ,IS_FIRST_IN_DT,COLOR,IS_ORGI_ITEM,CP_SEQ,IS_MALL,STORE_ID,BRAND_SEQ", facet.sort: "count", start: "0", q: "*:*", bf: "product(SM_SOLDQTY,0.01)", group.field: "NEW_SPEC_SEQ", group: "true", facet.field: [ "{!ex=aa}CP_SEQ", "IS_MALL" ], group.sort: "IS_PRE_ORD desc, MULTIPARTS_NUM asc, SALEQTY desc, IS_BOTTOM asc,score desc, SM_SOLDQTY desc ,IS_MAIN_SKU desc,SM_SOLDQTY desc,SM_SEQ desc", qt: "/search_ik", fq: "ISLIFEEXPIRED:0 AND SM_STATUS:1 AND(((KEYWORD:test OR STORE_NAME:test OR SM_SEQ:test OR GROUP_TITLE:test))) AND NOT BANNED_CHANNEL:(1)" } },
2016-02-25 17:12:40

4 Answers

q query is the main query of the Request.
It is the one that would allow you to actually search over multiple fields.
q query would decide what score each of the document has and hence would take part in the relevancy calculation.

q=*:* will just return all the documents with a same score.

fq is the filter query used to filter the documents and is not related to search.
So if you have any fix value which you want to filter on you should use filters to limit your results.
fq does not affect scoring of the results.
While filtering, Solr uses Filter cache so enhance the performance for the subsequent filter queries.

So ideally, you should check what the requirement demands, if you want to search should always useq and if you want to filter/limit results you should use fq.

Facets are just a addon to the results and do not effect your results.

2016-02-25 17:22:16

The q parameter takes your query and execute against the index. Then you can use filter queries (can use multiple filter queries) to filter the results.

For example your query can look like this.

q=author:shakespeare

this will match the documents which has 'shakespeare' in the 'author' field. Then you can use filter queries like this.

fq=title:hamlet
fq=type:play

Those will filter the results based on the other fields. You can even filter on the same field.

The query syntax is similar for both q and fq parameters

2016-02-25 17:18:00

q

Solr 中用来搜索的查询。有关该语法的完整描述。可以通过追加一个分号和已索引且未进行断词的字段(下面会进行解释)的名称来包含排序信息。默认的排序是 score desc,指按记分降序排序。

q=myField:Java AND otherField:developerWorks; date asc

此查询搜索指定的两个字段,并根据一个日期字段对结果进行排序。

fq

提供一个可选的筛选器查询。查询结果被限制为仅搜索筛选器查询返回的结果。筛选过的查询由 Solr 进行缓存。它们对提高复杂查询的速度非常有用。

任何可以用 q 参数传递的有效查询,排序信息除外。

2016-02-25 17:17:45

A FilterQuery ONLY stores document IDS. This makes it very fast to apply the filter to include/exclude documents. Good examples of this are when filtering products from search based on Country, Product Type, Availability, etc.

A normal query can perform the exact same function, but it has a very complex scoring system to determine "relevance". I believe the documentation is indicating that scoring is only done on the Main Query, not on the Filter Query. This should also increase query speed.

So, I can query for:

description:Kohler AND productType:Toilet

Or I can query for:

description:Kohler
with a FQ of productType:Toilet

The results would be the same, but the scores would be different. Also, if you get many different queries throughout the day that are for productType:Toilet, the FilterQuery would be cached making the overall query time faster.

2016-02-25 17:18:46
您不能回答该问题或者回答已经关闭!

相关文章推荐

  • C#中using指令的几种用法

    using + 命名空间名字,这样可以在程序中直接用命令空间中的类型,而不必指定类型的详细命名空间,类似于Java的import,这个功能也是最常用的,几乎每个cs的程序都会用到

  • C#实例解析适配器设计模式

    将一个类的接口变成客户端所期待的另一种接口,从而使原本因接口不匹配而无法在一起工作的两个类能够一起工作

  • C#开发高性能Log Help类设计开发

    项目中要在操作数据库的异常处理中加入写Log日志,对于商业上有要求,写log时对其它操作尽可能影响小,不能因为加入log导致耗时太多

  • Async和Await使异步编程更简单

    C#5.0中async和await两个关键字,这两个关键字简化了异步编程,之所以简化了,还是因为编译器给我们做了更多的工作

  • C#开发中的反射机制

    反射的定义:审查元数据并收集关于它的类型信息的能力。元数据(编译以后的最基本数据单元)就是一大堆的表,当编译程序集或者模块时,编译器会创建一个类定义表,一个字段定义表,和一个方法定义表等

  • C#运行时相互关系

    C#运行时相互关系,包括运行时类型、对象、线程栈和托管堆之间的相互关系,静态方法、实例方法和虚方法的区别等等

  • C#协变和逆变

    “协变”是指能够使用与原始指定的派生类型相比,派生程度更大的类型,“逆变”则是指能够使用派生程度更小的类型

  • 使用托管C++粘合C#和C++代码(二)

    本文实现一下C++代码调用C#代码的过程。我构造一个简单并且直观的例子:通过C++ UI 触发C# UI.

  • C#基础概念之延迟加载

    延迟加载(lazy load)是Hibernate3关联关系对象默认的加载方式,延迟加载机制是为了避免一些无谓的性能开销而提出来的,所谓延迟加载就是当在真正需要数据的时候,才真正执行数据加载操作

  • C#中的索引器的简单理解和用法

    C#中的类成员可以是任意类型,包括数组和集合。当一个类包含了数组和集合成员时,索引器将大大简化对数组或集合成员的存取操作

  • 使用托管C++粘合C#和C++代码(一)

    C#在xml读写,数据库操纵,界面构造等很多方面性能卓越;C++的效率高,是底层开发的必备武器

  • 深入C# 序列化(Serialize)、反序列化(Deserialize)

    C#中的序列化和反序列化,序列化是.NET运行时环境用来支持用户定义类型的流化的机制