本文整理汇总了Java中org.apache.solr.core.SolrCore.getLatestSchema方法的典型用法代码示例。如果您正苦于以下问题:Java SolrCore.getLatestSchema方法的具体用法?Java SolrCore.getLatestSchema怎么用?Java SolrCore.getLatestSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.core.SolrCore
的用法示例。
在下文中一共展示了SolrCore.getLatestSchema方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWithPolyFieldsAndFieldBoost
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testWithPolyFieldsAndFieldBoost() {
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
assertFalse(schema.getField("store").omitNorms());
assertTrue(schema.getField("store_0_coordinate").omitNorms());
assertTrue(schema.getField("store_1_coordinate").omitNorms());
assertFalse(schema.getField("amount").omitNorms());
assertTrue(schema.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_currency").omitNorms());
assertTrue(schema.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_amount_raw").omitNorms());
SolrInputDocument doc = new SolrInputDocument();
doc.addField( "store", "40.7143,-74.006", 3.0f );
doc.addField( "amount", "10.5", 3.0f );
Document out = DocumentBuilder.toDocument( doc, schema );
assertNotNull( out.get( "store" ) );
assertNotNull( out.get( "amount" ) );
assertNotNull(out.getField("store_0_coordinate"));
//NOTE: As the subtypes have omitNorm=true, they must have boost=1F, otherwise this is going to fail when adding the doc to Lucene.
assertTrue(1f == out.getField("store_0_coordinate").boost());
assertTrue(1f == out.getField("store_1_coordinate").boost());
assertTrue(1f == out.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_currency").boost());
assertTrue(1f == out.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_amount_raw").boost());
}
示例2: testSourceGlobMatchesNoDynamicOrExplicitField
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testSourceGlobMatchesNoDynamicOrExplicitField()
{
// SOLR-4650: copyField source globs should not have to match an explicit or dynamic field
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
assertNull("'testing123_*' should not be (or match) a dynamic or explicit field", schema.getFieldOrNull("testing123_*"));
assertTrue("schema should contain dynamic field '*_s'", schema.getDynamicPattern("*_s").equals("*_s"));
assertU(adoc("id", "A5", "sku1", "10-1839ACX-93", "testing123_s", "AAM46"));
assertU(commit());
Map<String,String> args = new HashMap<>();
args.put( CommonParams.Q, "text:AAM46" );
args.put( "indent", "true" );
SolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
assertQ("sku2 copied to text", req
,"//*[@numFound='1']"
,"//result/doc[1]/str[@name='id'][.='A5']"
);
}
示例3: testMultiValuedFieldAndDocBoosts
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
public void testMultiValuedFieldAndDocBoosts() throws Exception {
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
SolrInputDocument doc = new SolrInputDocument();
doc.setDocumentBoost(3.0f);
SolrInputField field = new SolrInputField( "foo_t" );
field.addValue( "summer time" , 1.0f );
field.addValue( "in the city" , 5.0f ); // using boost
field.addValue( "living is easy" , 1.0f );
doc.put( field.getName(), field );
Document out = DocumentBuilder.toDocument( doc, schema );
IndexableField[] outF = out.getFields( field.getName() );
assertEquals("wrong number of field values",
3, outF.length);
// since Lucene no longer has native documnt boosts, we should find
// the doc boost multiplied into the boost o nthe first field value
// all other field values should be 1.0f
// (lucene will multiply all of the field boosts later)
assertEquals(15.0f, outF[0].boost(), 0.0f);
assertEquals(1.0f, outF[1].boost(), 0.0f);
assertEquals(1.0f, outF[2].boost(), 0.0f);
}
示例4: testSearchDetails
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testSearchDetails() throws Exception {
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
double[] xy = new double[]{35.0, -79.34};
String point = xy[0] + "," + xy[1];
//How about some queries?
//don't need a parser for this path currently. This may change
assertU(adoc("id", "0", "home_ns", point));
assertU(commit());
SchemaField home = schema.getField("home_ns");
PointType pt = (PointType) home.getType();
assertEquals(pt.getDimension(), 2);
Query q = pt.getFieldQuery(null, home, point);
assertNotNull(q);
assertTrue(q instanceof BooleanQuery);
//should have two clauses, one for 35.0 and the other for -79.34
BooleanQuery bq = (BooleanQuery) q;
BooleanClause[] clauses = bq.getClauses();
assertEquals(clauses.length, 2);
clearIndex();
}
示例5: getDefaultSelector
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
/**
* Returns true if the field doesn't match any schema field or dynamic field,
* or if the matched field's type is BoolField
*/
@Override
public FieldMutatingUpdateProcessor.FieldNameSelector
getDefaultSelector(final SolrCore core) {
return new FieldMutatingUpdateProcessor.FieldNameSelector() {
@Override
public boolean shouldMutate(final String fieldName) {
final IndexSchema schema = core.getLatestSchema();
FieldType type = schema.getFieldTypeNoEx(fieldName);
return (null == type) || type instanceof DateValueFieldType;
}
};
}
示例6: testIsDynamicField
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testIsDynamicField() throws Exception {
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
assertFalse( schema.isDynamicField( "id" ) );
assertTrue( schema.isDynamicField( "aaa_i" ) );
assertFalse( schema.isDynamicField( "no_such_field" ) );
}
示例7: getDefaultSelector
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
/**
* Returns true if the field doesn't match any schema field or dynamic field,
* or if the matched field's type is compatible
* @param core Where to get the current schema from
*/
@Override
public FieldMutatingUpdateProcessor.FieldNameSelector
getDefaultSelector(final SolrCore core) {
return new FieldMutatingUpdateProcessor.FieldNameSelector() {
@Override
public boolean shouldMutate(final String fieldName) {
final IndexSchema schema = core.getLatestSchema();
FieldType type = schema.getFieldTypeNoEx(fieldName);
return (null == type) || isSchemaFieldTypeCompatible(type);
}
};
}
示例8: getDefaultSelector
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
/**
* Returns true if the field doesn't match any schema field or dynamic field,
* or if the matched field's type is BoolField
*/
@Override
public FieldMutatingUpdateProcessor.FieldNameSelector
getDefaultSelector(final SolrCore core) {
return new FieldMutatingUpdateProcessor.FieldNameSelector() {
@Override
public boolean shouldMutate(final String fieldName) {
final IndexSchema schema = core.getLatestSchema();
FieldType type = schema.getFieldTypeNoEx(fieldName);
return (null == type) || (type instanceof BoolField);
}
};
}
示例9: testRuntimeFieldCreation
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testRuntimeFieldCreation() {
// any field manipulation needs to happen when you know the core will not
// be accepting any requests. Typically this is done within the inform()
// method. Since this is a single threaded test, we can change the fields
// willi-nilly
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
final String fieldName = "runtimefield";
SchemaField sf = new SchemaField( fieldName, schema.getFieldTypes().get( "string" ) );
schema.getFields().put( fieldName, sf );
// also register a new copy field (from our new field)
schema.registerCopyField( fieldName, "dynamic_runtime" );
schema.refreshAnalyzers();
assertU(adoc("id", "10", "title", "test", fieldName, "aaa"));
assertU(commit());
SolrQuery query = new SolrQuery( fieldName+":aaa" );
query.set( "indent", "true" );
SolrQueryRequest req = new LocalSolrQueryRequest( core, query );
assertQ("Make sure they got in", req
,"//*[@numFound='1']"
,"//result/doc[1]/int[@name='id'][.='10']"
);
// Check to see if our copy field made it out safely
query.setQuery( "dynamic_runtime:aaa" );
assertQ("Make sure they got in", req
,"//*[@numFound='1']"
,"//result/doc[1]/int[@name='id'][.='10']"
);
clearIndex();
}
示例10: getDefaultSelector
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Override
public FieldMutatingUpdateProcessor.FieldNameSelector
getDefaultSelector(final SolrCore core) {
return new FieldMutatingUpdateProcessor.FieldNameSelector() {
@Override
public boolean shouldMutate(final String fieldName) {
final IndexSchema schema = core.getLatestSchema();
FieldType type = schema.getFieldTypeNoEx(fieldName);
return (null == type);
}
};
}
示例11: isHiddenFile
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
public static boolean isHiddenFile(SolrQueryRequest req, SolrQueryResponse rsp, String fnameIn, boolean reportError,
Set<String> hiddenFiles) {
String fname = fnameIn.toUpperCase(Locale.ROOT);
if (hiddenFiles.contains(fname) || hiddenFiles.contains("*")) {
if (reportError) {
log.error("Cannot access " + fname);
rsp.setException(new SolrException(SolrException.ErrorCode.FORBIDDEN, "Can not access: " + fnameIn));
}
return true;
}
// This is slightly off, a valid path is something like ./schema.xml. I don't think it's worth the effort though
// to fix it to handle all possibilities though.
if (fname.indexOf("..") >= 0 || fname.startsWith(".")) {
if (reportError) {
log.error("Invalid path: " + fname);
rsp.setException(new SolrException(SolrException.ErrorCode.FORBIDDEN, "Invalid path: " + fnameIn));
}
return true;
}
// Make sure that if the schema is managed, we don't allow editing. Don't really want to put
// this in the init since we're not entirely sure when the managed schema will get initialized relative to this
// handler.
SolrCore core = req.getCore();
IndexSchema schema = core.getLatestSchema();
if (schema instanceof ManagedIndexSchema) {
String managed = schema.getResourceName();
if (fname.equalsIgnoreCase(managed)) {
return true;
}
}
return false;
}
示例12: testCopyFieldWithFieldBoost
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testCopyFieldWithFieldBoost() {
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
assertFalse(schema.getField("title").omitNorms());
assertTrue(schema.getField("title_stringNoNorms").omitNorms());
SolrInputDocument doc = new SolrInputDocument();
doc.addField( "title", "mytitle", 3.0f );
Document out = DocumentBuilder.toDocument( doc, schema );
assertNotNull( out.get( "title_stringNoNorms" ) );
assertTrue("title_stringNoNorms has the omitNorms attribute set to true, if the boost is different than 1.0, it will fail",1.0f == out.getField( "title_stringNoNorms" ).boost() );
assertTrue("It is OK that title has a boost of 3",3.0f == out.getField( "title" ).boost() );
}
示例13: testSchemaLoading
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testSchemaLoading()
{
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
SchemaField uniqueKey = schema.getUniqueKeyField();
assertFalse( uniqueKey.isRequired() );
assertFalse( schema.getRequiredFields().contains( uniqueKey ) );
}
示例14: testMockExchangeRateProvider
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testMockExchangeRateProvider() throws Exception {
SolrCore core = h.getCore();
IndexSchema schema = core.getLatestSchema();
SchemaField amount = schema.getField("mock_amount");
// A few tests on the provider directly
ExchangeRateProvider p = ((CurrencyField)amount.getType()).getProvider();
Set<String> availableCurrencies = p.listAvailableCurrencies();
assert(availableCurrencies.size() == 3);
assert(p.reload() == true);
assert(p.getExchangeRate("USD", "EUR") == 0.8);
}
示例15: DataImporter
import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
DataImporter(SolrCore core, String handlerName) {
this.handlerName = handlerName;
this.core = core;
this.schema = core.getLatestSchema();
}