solr

Exclude draft articles from Solr index with Sunspot

雨燕双飞 提交于 2019-12-19 08:53:04
问题 I have an indexed model called Article and I don't want solr to index unpublished articles. class Article < ActiveRecord::Base searchable do text :title text :body end end How can I specify that article that is not #published? should not be indexed? 回答1: Be sure to index the published status. class Article < ActiveRecord::Base searchable do text :title text :body boolean :is_published, :using => :published? end end Then add a filter to your query Sunspot.search(Article) do |search| search

Jetty/SOLR Admin Panel Password

a 夏天 提交于 2019-12-19 08:12:33
问题 I am applying authentication on SOLR Admin Panel using jetty. I have read so many tutorials and implemented using following steps: Added following code in /solr/core/etc/jetty.xml : <Call name="addBean"> <Arg> <New class="org.eclipse.jetty.security.HashLoginService"> <Set name="name">Test Realm</Set> <Set name="config"><SystemProperty name="jetty.home" default="."/>/var/www/solr/core/etc/realm.properties</Set> <Set name="refreshInterval">0</Set> </New> </Arg> </Call> Added following code in

Solr4.4配置Tomcat7

随声附和 提交于 2019-12-19 07:36:27
下载好资源: 1.http://lucene.apache.org/solr/下载了目前的最新版solr-4.4.0 2.下载tomcat7 zip 配置流程: 1,在D盘建立一个SolrHome文件夹来存放solr的配置文件等, 例如:在D盘目录下穿件一个SolrHome文件夹:D:\solrwork\solrhome 2,在刚解压的solr-4.4.0,找到D:\solrwork\solr-4.4.0\example下找到solr文件夹, 复制到SolrHome下变成D:\solrwork\solrhome\solr. 3,将D:\solrwork\solr-4.4.0\example\webapps\solr.war 复制到tomcat中的\webapps下并重命名为solr,启动tomcat,解压war包后,停止tomcat. 4,在解压后的solr中找到web.xml,打开:将<env-entry-value>的值设为SolrHome的目录地址 <env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>D:/solrwork/solrhome/solr</env-entry-value> <env-entry-type>java.lang.String</env-entry-type>

Order by an expression in Solr

自古美人都是妖i 提交于 2019-12-19 07:28:07
问题 In SQL you can order by an expression like: SELECT * FROM a ORDER BY CASE WHEN a.Category = 20 THEN 1 ELSE 0 DESC so records who have Category = 20 are on top. Is this possible in Solr? 回答1: Solr doesn't have an if/then (at least not until 4.0), but it does have a map function and the ability to use function queries in your sort. You can probably use something like this in your sort to achieve what you're after: ?q=*&sort=map(category,20,20,case,0),score desc (untested) Here is a thread that

facet dynamic fields with apache solr

僤鯓⒐⒋嵵緔 提交于 2019-12-19 06:18:23
问题 I have defined dynamic field in ApacheSolr: I use it to store products features like: color_feature, diameter_feature, material_feature and so on. Number of those fields are not constant becouse products are changing. Is it possible to get facet result for all those dynamic fields with the same query or do I need to write always all fields in a query like ... facet.field=color_feature&facet.field=diameter_feature&facet.field=material_feature&facet.field= ... 回答1: Solr currently does not

Solr Function Query : How to use “score” field for creating custom scoring

℡╲_俬逩灬. 提交于 2019-12-19 05:45:15
问题 After searching extensively and coming across answers such as these - Solr: Sort by score & an int field value Use function query for boosting score in Solr I am still unable to solve the following problem : How do I use the "score" field of a document to create a new scoring function and rank the results accordingly . Something like this - new_score = score * my_other_field Current Query - http://localhost:8984/solr/suggest_new/select?q=tom&wt=json&indent=true&bq=_val_:"product(score,count

SOLR travel site: on date queries

好久不见. 提交于 2019-12-19 04:44:06
问题 I was looking to implement SOLR for a Hotel bookings site. Search based on location, hotel names, facilities works very well and so does the faceting. What I have not been able to figure out is how to search for a hotel given Checkin and Checkout dates. Eg: User will search for search query - "Hotels in Newyork" and select CheckIn Date: 10th Feb 2012 and CheckOut Date: 12 Feb 2012 from the date selection box. This is how I have the data - Hotel_Name 10thFeb2012 11thFEB2012 ........ 31DEC2012

Solr 4.0 How can I change the spellchecker analysers so they are all the same?

十年热恋 提交于 2019-12-19 04:12:21
问题 I've just upgraded from 3.6.1 to 4.0 solr and the spelchecker stopped working. I'm using the standard config /spell request handler to test the spellchecking. I keep getting the "All checkers need to use the same Analyzer" error. (https://svn.apache.org/repos/asf/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/ConjunctionSolrSpellChecker.java) How can I change the spellchecker analysers so they are all the same? This is the handler I'm using: <requestHandler name="/spell" class=

Multiple Indexes in same Solr Core..?

筅森魡賤 提交于 2019-12-19 04:07:58
问题 I am using Apache Solr..I have the following Scenario.. : I have Two table in my PostGreSQL database. One is " Cars ". Other is " Dealers " Now i have a data-config file for Cars like the following : <document name="offerings"> <entity name="jc_offerings" query="select * from jc_offerings" > <field column="id" name="id" /> <field column="name" name="name" /> <field column="display_name" name="display_name" /> <field column="extra" name="extra" /> </entity> </document> I have a similar data-

why CPU usage close to reach to 100% when i use SOLR query all document

…衆ロ難τιáo~ 提交于 2019-12-19 04:07:22
问题 I have a application using SOLR to query 2 million+ document and sort by time. Query URL param like this /select?sort=p_review_date desc&rows=10&start=0&q=*:* , parameter start is variable value, every request increased 10. When i make performance stress testing, the SOLR server CPU usage close to reach to 100%. Question: 1.What causes high CPU usage? 2.Is there a way to make low CPU usage, such as cache or other configuration. This is a part section for query cache configuration in