You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
4.1 KiB
89 lines
4.1 KiB
13 years ago
|
/**
|
||
|
* schema_p
|
||
|
* Copyright 2011 by Michael Peter Christen, mc@yacy.net, Frankfurt am Main, Germany
|
||
|
* First released 13.01.2012 at http://yacy.net
|
||
|
*
|
||
|
* $LastChangedDate: 2011-04-14 00:04:23 +0200 (Do, 14 Apr 2011) $
|
||
|
* $LastChangedRevision: 7653 $
|
||
|
* $LastChangedBy: orbiter $
|
||
|
*
|
||
|
* 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/>.
|
||
|
*/
|
||
|
|
||
12 years ago
|
import net.yacy.cora.federate.solr.YaCySchema;
|
||
12 years ago
|
import net.yacy.cora.protocol.HeaderFramework;
|
||
13 years ago
|
import net.yacy.cora.protocol.RequestHeader;
|
||
12 years ago
|
import net.yacy.cora.protocol.ResponseHeader;
|
||
13 years ago
|
import net.yacy.search.Switchboard;
|
||
12 years ago
|
import net.yacy.search.index.SolrConfiguration;
|
||
12 years ago
|
import net.yacy.server.serverObjects;
|
||
|
import net.yacy.server.serverSwitch;
|
||
12 years ago
|
import net.yacy.server.servletProperties;
|
||
13 years ago
|
|
||
12 years ago
|
public class schema {
|
||
13 years ago
|
|
||
13 years ago
|
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, final serverSwitch env) {
|
||
13 years ago
|
// return variable that accumulates replacements
|
||
12 years ago
|
final servletProperties prop = new servletProperties();
|
||
13 years ago
|
final Switchboard sb = (Switchboard) env;
|
||
|
|
||
|
// write scheme
|
||
|
int c = 0;
|
||
12 years ago
|
/*
|
||
|
//<field name="#[solrname]#" type="#[type]#"#(indexedChecked)#:: indexed="true"#(/indexedChecked)##(storedChecked)#:: stored="true"#(/storedChecked)##(multiValuedChecked)#:: multiValued="true"#(/multiValuedChecked)##(omitNormsChecked)#:: omitNorms="true"#(/omitNormsChecked)#/>
|
||
|
if (sb == null) {
|
||
|
for (SolrType type : SolrType.values()) {
|
||
|
prop.put("fields_" + c + "_solrname", field.getSolrFieldName());
|
||
|
prop.put("fields_" + c + "_type", field.getType().printName());
|
||
|
prop.put("fields_" + c + "_comment", field.getComment());
|
||
|
prop.put("fields_" + c + "_indexedChecked", field.isIndexed() ? 1 : 0);
|
||
|
prop.put("fields_" + c + "_storedChecked", field.isStored() ? 1 : 0);
|
||
|
prop.put("fields_" + c + "_multiValuedChecked", field.isMultiValued() ? 1 : 0);
|
||
|
prop.put("fields_" + c + "_omitNormsChecked", field.isOmitNorms() ? 1 : 0);
|
||
|
c++;
|
||
|
}
|
||
|
prop.put("fields", c);
|
||
|
} else {
|
||
|
*/
|
||
12 years ago
|
SolrConfiguration solrScheme = sb.index.fulltext().getSolrScheme();
|
||
12 years ago
|
for (YaCySchema field : YaCySchema.values()) {
|
||
12 years ago
|
if (solrScheme.contains(field.name())) {
|
||
13 years ago
|
prop.put("fields_" + c + "_solrname", field.getSolrFieldName());
|
||
|
prop.put("fields_" + c + "_type", field.getType().printName());
|
||
|
prop.put("fields_" + c + "_comment", field.getComment());
|
||
|
prop.put("fields_" + c + "_indexedChecked", field.isIndexed() ? 1 : 0);
|
||
|
prop.put("fields_" + c + "_storedChecked", field.isStored() ? 1 : 0);
|
||
|
prop.put("fields_" + c + "_multiValuedChecked", field.isMultiValued() ? 1 : 0);
|
||
|
prop.put("fields_" + c + "_omitNormsChecked", field.isOmitNorms() ? 1 : 0);
|
||
|
c++;
|
||
13 years ago
|
}
|
||
|
}
|
||
|
prop.put("fields", c);
|
||
12 years ago
|
//}
|
||
13 years ago
|
|
||
12 years ago
|
prop.put("solruniquekey",YaCySchema.id.getSolrFieldName());
|
||
|
prop.put("solrdefaultsearchfield",YaCySchema.text_t.getSolrFieldName());
|
||
12 years ago
|
|
||
|
|
||
|
// add CORS Access header
|
||
|
final ResponseHeader outgoingHeader = new ResponseHeader(200);
|
||
|
outgoingHeader.put(HeaderFramework.CORS_ALLOW_ORIGIN, "*");
|
||
|
prop.setOutgoingHeader(outgoingHeader);
|
||
|
|
||
13 years ago
|
// return rewrite properties
|
||
|
return prop;
|
||
|
}
|
||
|
}
|