mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
91a0401d59
structure, but is not filled yet. To have the opportunity of a second core, multi-core functionality had to be implemented to the deep-embedded solr: - migrated the solr_40 directory content to a subdirectory 'collection1'; the previously used default core is now called collection1 - added solr_40/webgraph subdirectory as second core - added a servlet configuration for the second core 'webgraph' in /IndexSchema_p.html - added instance handling as addition to solr connections: all solr connectors are now instances of an solr 'instance' object; this required a complete re-design of the solr embedding - migrated also caching and sharding ontop of new instance handling - migrated the search apis to handle now the access to a specific core, the default core named 'collection1' - migrated the remote solr search interface to access shards of cores; for the yacy remote search the default core is now called 'solr'; using the peer address as solr address - migrated the solr backup and restore process: old backups cannot be used after this migration! - redesign of solr instance handling in all methods which access the instances: they cannot hold copies of these instances any more; the must retrieve the actuall connection object every time they want to write to it (this solves also some bugs when switching the index/network) - added another schema 'solr.webgraph.schema', the old solr.keys.list is replaced by solr.collection.schema
101 lines
4.3 KiB
Java
101 lines
4.3 KiB
Java
/**
|
|
* RankingSolr_p
|
|
* Copyright 2012 by Michael Peter Christen
|
|
* First released 30.11.2012 at http://yacy.net
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library 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
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with this program in the file lgpl21.txt
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import java.util.Map;
|
|
|
|
import net.yacy.cora.federate.solr.Boost;
|
|
import net.yacy.cora.protocol.RequestHeader;
|
|
import net.yacy.search.Switchboard;
|
|
import net.yacy.search.SwitchboardConstants;
|
|
import net.yacy.search.query.SearchEventCache;
|
|
import net.yacy.search.schema.CollectionSchema;
|
|
import net.yacy.server.serverObjects;
|
|
import net.yacy.server.serverSwitch;
|
|
|
|
public class RankingSolr_p {
|
|
|
|
|
|
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
|
final Switchboard sb = (Switchboard) env;
|
|
|
|
// clean up all search events
|
|
SearchEventCache.cleanupEvents(true);
|
|
sb.index.fulltext().clearCache(); // every time the ranking is changed we need to remove old orderings
|
|
|
|
if (post != null && post.containsKey("EnterDoublecheck")) {
|
|
Boost.RANKING.setMinTokenLen(post.getInt("minTokenLen", 3));
|
|
Boost.RANKING.setQuantRate(post.getFloat("quantRate", 0.5f));
|
|
sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_DOUBLEDETECTION_MINLENGTH, Boost.RANKING.getMinTokenLen());
|
|
sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_DOUBLEDETECTION_QUANTRATE, Boost.RANKING.getQuantRate());
|
|
}
|
|
|
|
if (post != null && post.containsKey("ResetDoublecheck")) {
|
|
Boost.RANKING.setMinTokenLen(3);
|
|
Boost.RANKING.setQuantRate(0.5f);
|
|
sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_DOUBLEDETECTION_MINLENGTH, Boost.RANKING.getMinTokenLen());
|
|
sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_DOUBLEDETECTION_QUANTRATE, Boost.RANKING.getQuantRate());
|
|
}
|
|
|
|
if (post != null && post.containsKey("EnterRanking")) {
|
|
StringBuilder boostString = new StringBuilder(); // SwitchboardConstants.SEARCH_RANKING_SOLR_BOOST;
|
|
for (Map.Entry<String, String> entry: post.entrySet()) {
|
|
if (entry.getKey().startsWith("boost")) {
|
|
String fieldName = entry.getKey().substring(6);
|
|
CollectionSchema field = CollectionSchema.valueOf(fieldName);
|
|
if (field == null) continue;
|
|
try {
|
|
float boost = Float.parseFloat(entry.getValue());
|
|
if (boostString.length() > 0) boostString.append(',');
|
|
boostString.append(field.getSolrFieldName()).append('^').append(Float.toString(boost));
|
|
} catch (NumberFormatException e) {
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
if (boostString.length() > 0) {
|
|
String s = boostString.toString();
|
|
sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_BOOST, s);
|
|
Boost.RANKING.updateBoosts(s);
|
|
}
|
|
|
|
}
|
|
|
|
if (post != null && post.containsKey("ResetRanking")) {
|
|
Boost.RANKING.initDefaults();
|
|
}
|
|
|
|
final serverObjects prop = new serverObjects();
|
|
prop.put("minTokenLen", Boost.RANKING.getMinTokenLen());
|
|
prop.put("quantRate", Boost.RANKING.getQuantRate());
|
|
int i = 0;
|
|
for (Map.Entry<CollectionSchema, Float> entry: Boost.RANKING.entrySet()) {
|
|
CollectionSchema field = entry.getKey();
|
|
float boost = entry.getValue();
|
|
prop.put("boosts_" + i + "_field", field.getSolrFieldName());
|
|
prop.put("boosts_" + i + "_boost", Float.toString(boost));
|
|
i++;
|
|
}
|
|
prop.put("boosts", i);
|
|
|
|
return prop;
|
|
}
|
|
|
|
}
|