我的问题是非常具体的。我有一个来自Sunspot查询的结果集合,
@search = Product.search do
with(:website_id, id)
with(:archived_at, nil)
with(:category_id, restrictive_category_ids)
fulltext search_string do
phrase_fields(:name => 1, :artist => 3, :tag_list => 2)
minimum_match 0 #enables search to be performed by each word, not the whole phrase.
end
paginate :page => 1, :per_page => 2
end
@products = @search.results
Run Code Online (Sandbox Code Playgroud)
这将产生几页结果,每页2张。所有这些都已在Sunspot控制台中进行了验证。
我的问题是尝试将will_paginate用于结果。例如,在视图中:
<%= will_paginate @products, param_name: 'products', class: 'pagination-nav' %>
Run Code Online (Sandbox Code Playgroud)
由于@products在初始查询中仅返回2个结果,因此will_paginate认为只有2个结果,因此甚至不会出现。如果将@products替换为Product.all,则它显然会出现并显示结果页面。
因此,我不确定要告诉will_paginate实际有多少结果,因此不确定要显示多少页。当然,我可以对所有这些记录进行单独的查询,但这将对应用程序造成重大影响,并且鉴于Sunspot声称可以与will_paginate一起使用,我认为必须有一种更简单的方法。
谢谢你的帮助!
我对eDisMax中的qf和tie参数感到困惑
根据文件:
该QF是用来指定要搜索的领域,而领带是使用指定的所有其他领域(除了得分最高的领域)的影响,以总比分。
我的困惑是,因为我们已经指定了要搜索的字段(假设仅指定一个字段),为什么我们仍然能够获得其他字段来影响总结果(我想这一定是我对edismax的工作方式的误解,但这也是我的困惑。)?
还是这意味着每次edismax都会计算所有字段中的所有得分并将它们与最终得分打成平手(即使我们仅指定一个字段)?
我正在创建一个搜索应用程序,它集中使用Solr(5.2.1)分面功能.一个要求是限制指定字段的前缀返回的facet数.
标准的Solr查询语法适用于单个前缀值:
/select?q=*%3A*&rows=0&wt=json&indent=true&facet=true&facet.field=DocumentKind&f.DocumentKind.facet.prefix=faq
Run Code Online (Sandbox Code Playgroud)
输出:
"facet_counts": {
"facet_queries": {},
"facet_fields": {
"DocumentKind": {
"faq": 1523
}
...
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我必须使用多个前缀限制字段上的facet时,这不起作用:
/select?q=*%3A*&rows=0&wt=json&indent=true&facet=true&facet.field=DocumentKind&f.DocumentKind.facet.prefix=manual&f.DocumentKind.facet.prefix=faq
Run Code Online (Sandbox Code Playgroud)
我预计它会返回这样的东西:
"facet_counts": {
"facet_queries": {},
"facet_fields": {
"DocumentKind": {
"faq": 1523,
"manual": 2366
}
...
Run Code Online (Sandbox Code Playgroud)
但它提供与以前相同的输出.
在上面的例子中,我匹配整个facet值,但在实际使用情况下,我真的必须匹配前缀.为简洁起见,我展示了这个例子.
我可以在我的应用程序中对此进行过滤,但Solr返回的数据大小非常重要.
为什么我们使用搜索引擎solr,elastic search或任何其他搜索引擎,而不是active record像宝石一样ransack,meta_search.
我是搜索引擎选择的新手.
我知道索引行为和其他可用于搜索引擎.但想知道明智或大数据明智的搜索引擎有哪些帮助.
我正在创建一个购物网站,我很困惑,我该怎么办?
任何帮助对我来说都是非凡的
我们在弹性搜索和搜索技术的solr之间提到了很多差异.提到的差异主要是数据格式,API可访问性,分析支持,适应性,云集成,地理空间搜索,索引等.
此外,在所有地方,他们都提到这两种搜索技术都建立在Apache Lucene之上.我有一个基本的问题,如果两者都建立在搜索解决方案之上(Lucene在这里),那么查询的工作方式肯定存在一些差异吗?就像我只从文本搜索方面看并留下所有其他东西一样,如何在ES和solr中执行文本搜索.搜索引擎搜索/优化的方式应该有一些配置/行为改变?我需要以文本字符串为例深入了解搜索的工作原理.
如果有人能解释我那会很棒:)
谢谢.
我在Windows 7机器上使用Solr 6.1.0.
我写了这个BAT文件来启动Solr:
set JAVA_HOME="F:\Users\username\Downloads\solr-6.1.0\jdk1.8.0_92\"
cd "F:\Users\username\Downloads\solr-6.1.0\bin\"
solr start -e cloud -noprompt
Run Code Online (Sandbox Code Playgroud)问题:Solr管理UI运行得很好,我可以查询样本集合,但是当我尝试创建新连接时,我得到错误:
Collection: collection1 operation: create failed:java.lang.IllegalArgumentException: Path must not end with / character
at org.apache.zookeeper.common.PathUtils.validatePath(PathUtils.java:58)
at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1024)
at org.apache.solr.common.cloud.SolrZkClient$5.execute(SolrZkClient.java:314)
at org.apache.solr.common.cloud.SolrZkClient$5.execute(SolrZkClient.java:311)
at org.apache.solr.common.cloud.ZkCmdExecutor.retryOperation(ZkCmdExecutor.java:60)
at org.apache.solr.common.cloud.SolrZkClient.exists(SolrZkClient.java:311)
at org.apache.solr.cloud.OverseerCollectionMessageHandler.validateConfig(OverseerCollectionMessageHandler.java:2491)
at org.apache.solr.cloud.OverseerCollectionMessageHandler.createCollection(OverseerCollectionMessageHandler.java:1838)
at org.apache.solr.cloud.OverseerCollectionMessageHandler.processMessage(OverseerCollectionMessageHandler.java:224)
at org.apache.solr.cloud.OverseerTaskProcessor$Runner.run(OverseerTaskProcessor.java:463)
at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$22(ExecutorUtil.java:229)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
null:org.apache.solr.common.SolrException: Path must not end with / character
at org.apache.solr.handler.admin.CollectionsHandler.handleResponse(CollectionsHandler.java:273)
at org.apache.solr.handler.admin.CollectionsHandler.handleRequestBody(CollectionsHandler.java:204)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:156)
at org.apache.solr.servlet.HttpSolrCall.handleAdminRequest(HttpSolrCall.java:663)
at …Run Code Online (Sandbox Code Playgroud) 尝试使用JDK 64bit 1.8.0在Windows Server 2008上设置solr 6.4.1
设置系统环境变量:
CLASSPATH = "C:\solr-6.4.1\dist\solr-core-6.4.1.jar"
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_121
PATH = "...;C:\Program Files\Java\jdk1.8.0_121\bin"
Run Code Online (Sandbox Code Playgroud)
当尝试通过cmd启动时(作为管理员)"solr start -p 8984"出现以下错误消息:
Error: Could not find or load main class org.apache.solr.util.SolrCLI
Failed removing old solr logs (...)
Run Code Online (Sandbox Code Playgroud)
我解压缩了solr-core.6.4.1.jar,SolrCLI实际上就在其中.
我在Solr中有一个名为的核心test。我已经摄取了2个嵌套的JSON文档。它们如下:
{"id":1, "path":"1.parent", "_childDocuments_":{"path":"2.parent.child"}}
Run Code Online (Sandbox Code Playgroud)
和
{"id":2, "path":"1.parent", "_childDocuments_":{"path":"2.parent.child"}}
Run Code Online (Sandbox Code Playgroud)
当我test通过浏览器查询核心以寻求父子关系的响应时,我更正了回复:
http://localhost:8983/solr/test/select?fl=*,[child%20parentFilter=path:1.parent%20childFilter=path:2.parent.child]&indent=on&q={!parent%20which=%22path:1.parent%22}&wt=json
{
"responseHeader":{
"status":0,
"QTime":2,
"params":{
"q":"{!parent which=\"path:1.parent\"}",
"indent":"on",
"fl":"*,[child parentFilter=path:1.parent childFilter=path:2.parent.child]",
"wt":"json"}},
"response":{"numFound":2,"start":0,"docs":[
{
"id":"1",
"path":["1.parent"],
"_childDocuments_.path":["2.parent.child"],
"_version_":1565913168462479360},
{
"id":"2",
"path":["1.parent"],
"_childDocuments_.path":["2.parent.child"],
"_version_":1565913171789611008}]
}}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试通过curl它运行相同的查询时显示错误:
$ curl 'http://localhost:8983/solr/test/select?fl=*,[child%20parentFilter=path:1.parent%20childFilter=path:2.parent.child]&indent=on&q={!parent%20which=%22path:1.parent%22}&wt=json'
curl: (3) [globbing] bad range in column 46
Run Code Online (Sandbox Code Playgroud)
我无法理解。虽然,我可以理解,curl请求给错误上column 46是一个特殊字符[的http请求。但是,然后它如何在浏览器中工作,我们如何通过发出请求curl?
我正在尝试运行solr 6.6.0教程并在运行之后:
bin/solr start -e cloud -noprompt
Run Code Online (Sandbox Code Playgroud)
它在端口8983和7574上启动solr但是无法使用以下错误创建入门集合:
ERROR: Failed to create collection 'gettingstarted' due to: {10.1.20.105:7574_solr=org.apache.solr.client.solrj.SolrServerException:IOException occured when talking to server at: http://10.1.20.105:7574/solr}
ERROR: Failed to create collection using command: [-name, gettingstarted, -shards, 2, -replicationFactor, 2, -confname, gettingstarted, -confdir, data_driven_schema_configs, -configsetsDir, /Users/rcarey/solr-6.6.0/server/solr/configsets, -solrUrl, http://localhost:8983/solr]
Run Code Online (Sandbox Code Playgroud)
看起来它试图在不同的ip上创建每个副本,而不是在同一个ip上创建不同的端口.10.1.20.105不是8983副本使用的IP.我不确定是否需要为此配置一些额外的东西,以便它使用一个IP.我将主机设置为localhost.
Solr Admin可在http:// localhost:8983/solr和http:// localhost:7574/solr上使用
我在日志中得到以下内容:
24/08/2017, 11:38:36 ERROR null OverseerCollectionMessageHandler Error from shard: http://10.1.20.105:7574/solr
24/08/2017, 11:38:36 ERROR null OverseerCollectionMessageHandler Error from shard: http://10.1.20.105:7574/solr
org.apache.solr.client.solrj.SolrServerException: IOException occured when talking to server at: …Run Code Online (Sandbox Code Playgroud) 我正在从此处运行Apache Solr教程:
http://lucene.apache.org/solr/guide/7_6/solr-tutorial.html
Solr正在运行,我可以在Web浏览器中运行查询。
教程中提到cURL了我不熟悉的内容。
我已经解压缩CURL到C:\Curl和包括卷曲在PATH environment variable:C:\Curl\curl-7.63.0-win64-mingw\bin
在Windows命令提示符下运行以下命令时,出现错误。我已经用谷歌搜索并尝试了无济于事的解决方案:
代码如下:
C:\Curl\curl-7.63.0-win64-mingw\bin>curl -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"name", "type":"text_general", "multiValued":false, "stored":true}}' http://localhost:8983/solr/films/schema
Run Code Online (Sandbox Code Playgroud)
产生以下错误:
curl: (3) unmatched brace in URL position 1:
{name:name,
^
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched close brace/bracket in URL position 12:
stored:true}}'
^
{
"responseHeader":{
"status":400,
"QTime":1},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"no …Run Code Online (Sandbox Code Playgroud)