Author: ssmiweve
Date: 2008-08-20 14:18:51 +0200 (Wed, 20 Aug 2008)
New Revision: 6783
Added:
trunk/generic.sesam/search-command-config/src/main/java/no/sesat/search/mode/config/SolrSearchConfig.java
Modified:
trunk/generic.sesam/search-command-control/default/src/main/java/no/sesat/search/mode/command/SolrSearchCommand.java
Log:
Issue SKER4949: (Solr SearchCommand implementation)
Added:
trunk/generic.sesam/search-command-config/src/main/java/no/sesat/search/mode/config/SolrSearchConfig.java
===================================================================
---
trunk/generic.sesam/search-command-config/src/main/java/no/sesat/search/mode/config/SolrSearchConfig.java
(rev 0)
+++
trunk/generic.sesam/search-command-config/src/main/java/no/sesat/search/mode/config/SolrSearchConfig.java
2008-08-20 12:18:51 UTC (rev 6783)
@@ -0,0 +1,99 @@
+/* Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ * SESAT is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SESAT is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
+ * AbstractXmlSearchConfiguration.java
+ *
+ * Created on June 12, 2006, 10:58 AM
+ *
+ */
+
+package no.sesat.search.mode.config;
+
+import no.sesat.search.mode.SearchModeFactory.Context;
+import no.sesat.search.mode.config.CommandConfig.Controller;
+import no.sesat.search.site.config.AbstractDocumentFactory;
+import no.sesat.search.site.config.AbstractDocumentFactory.ParseType;
+import org.w3c.dom.Element;
+
+/** Searching against a Solr index using the Solrj client.
+ *
+ * @version $Id$
+ */
[EMAIL PROTECTED]("SolrSearchCommand")
+public class SolrSearchConfig extends CommandConfig {
+
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ /**
+ * Holds value of property key for serverUrl.
+ */
+ private String serverUrl = "";
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Getter for property serverUrl.
+ * The value returned is the key used
+ * to look up the real value via SiteConfiguration(via in
configuration.properties)
+ *
+ * @return Value of property serverUrl.
+ */
+ public String getServerUrl() {
+ return this.serverUrl;
+ }
+
+ /**
+ * Setter for property serverUrl.
+ * @param serverUrl New value of property serverUrl.
+ */
+ public void setServerUrl(final String serverUrl) {
+ this.serverUrl = serverUrl;
+ }
+
+ @Override
+ public SolrSearchConfig readSearchConfiguration(
+ final Element element,
+ final SearchConfiguration inherit,
+ final Context context) {
+
+ super.readSearchConfiguration(element, inherit, context);
+
+ AbstractDocumentFactory.fillBeanProperty(this, inherit, "serverUrl",
ParseType.String, element, "");
+
+ return this;
+ }
+
+
+
+ // Z implementation ----------------------------------------------
+
+ // Y overrides ---------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Property changes on:
trunk/generic.sesam/search-command-config/src/main/java/no/sesat/search/mode/config/SolrSearchConfig.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
trunk/generic.sesam/search-command-control/default/src/main/java/no/sesat/search/mode/command/SolrSearchCommand.java
===================================================================
---
trunk/generic.sesam/search-command-control/default/src/main/java/no/sesat/search/mode/command/SolrSearchCommand.java
2008-08-20 10:49:01 UTC (rev 6782)
+++
trunk/generic.sesam/search-command-control/default/src/main/java/no/sesat/search/mode/command/SolrSearchCommand.java
2008-08-20 12:18:51 UTC (rev 6783)
@@ -19,10 +19,12 @@
import java.net.MalformedURLException;
import java.util.Map;
+import no.sesat.search.mode.config.SolrSearchConfig;
import no.sesat.search.result.BasicResultItem;
import no.sesat.search.result.BasicResultList;
import no.sesat.search.result.ResultItem;
import no.sesat.search.result.ResultList;
+import no.sesat.search.site.config.SiteConfiguration;
import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
@@ -33,8 +35,8 @@
import org.apache.solr.common.SolrDocumentList;
/** Searching against a Solr index using the Solrj client.
+ * see http://wiki.apache.org/solr/Solrj
*
- *
* @version $Id$
*/
public class SolrSearchCommand extends AbstractSearchCommand{
@@ -55,8 +57,12 @@
super(cxt);
try {
- server = new
CommonsHttpSolrServer("http://sch-solr-test01.dev.osl.basefarm.net:8080/solr");
+ // "http://sch-solr-test01.dev.osl.basefarm.net:8080/solr"
+ final String serverUrl =
((SolrSearchConfig)cxt.getSearchConfiguration()).getServerUrl();
+ final SiteConfiguration siteConf =
cxt.getDataModel().getSite().getSiteConfiguration();
+ server = new
CommonsHttpSolrServer(siteConf.getProperty(serverUrl));
+
} catch (MalformedURLException ex) {
LOG.error(ex.getMessage(), ex);
}
@@ -72,7 +78,8 @@
final SolrQuery query = new SolrQuery()
.setQuery(getTransformedQuery())
.setStart(getOffset())
- .setRows(getSearchConfiguration().getResultsToReturn());
+ .setRows(getSearchConfiguration().getResultsToReturn())
+
.setFields(getSearchConfiguration().getResultFieldMap().values().toArray(new
String[]{}));
// query
final QueryResponse response = server.query(query);
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits