Hi Rupert,
I got it working for version 0.12.0-SNAPSHOT, but as version 0.12.0 is
still not available through maven repository, I switched to version 0.11.0
which seems to be quite different.
Here is what I am doing for version 0.11.0 ...
public static final String TEST_YARD_ID = "testYard";
public static final String TEST_SOLR_CORE_NAME = "dbpedia";
protected static final String TEST_INDEX_REL_PATH = File.separatorChar
+ "target" + File.separatorChar
+
ManagedSolrServer.DEFAULT_SOLR_DATA_DIR;
private static final Logger log =
LoggerFactory.getLogger(SolrYardTest.class);
@BeforeClass
public static final void initYard() throws YardException {
// get the working directory
// use property substitution to test this feature!
String prefix = System.getProperty("basedir") == null ? "." :
"${basedir}";
String solrServerDir = prefix + TEST_INDEX_REL_PATH;
log.info("Test Solr Server Directory: " + solrServerDir);
System.setProperty(ManagedSolrServer.MANAGED_SOLR_DIR_PROPERTY,
solrServerDir);
SolrYardConfig config = new SolrYardConfig(TEST_YARD_ID,
TEST_SOLR_CORE_NAME);
config.setName("Solr Yard Test");
config.setDescription("The Solr Yard instance used to execute the
Unit Tests defined for the Yard Interface");
//use the default Solr Index configuration for this tests
config.setDefaultInitialisation(false);
// create the Yard used for the tests
yard = new SolrYard(config);
}
@Override
protected Yard getYard() {
return yard;
}
@Test
public void testFieldQuery() throws YardException {
Yard yard = getYard();
String field = "rdfs:label";
TextConstraint tc = new TextConstraint("sachin tendulkar",
PatternType.wildcard, false, "en");
FieldQuery query = yard.getQueryFactory().createFieldQuery();
query.addSelectedField(field);
query.addSelectedField(NamespaceEnum.rdf + "type");
query.setOffset(0);
query.setLimit(5);
query.setConstraint(field, tc);
QueryResultList<Representation> results =
yard.findRepresentation(query);
Representation result;
Iterator<Representation> it = results.iterator();
while ( it.hasNext() ) {
result = it.next();
log.info("ID: " + result.getId());
Iterator<Object> type_it = result.get(NamespaceEnum.rdf +
"type");
while (type_it.hasNext() ) {
log.info("type: " + type_it.next());
}
}
}
And I am getting the following error (also please note that I unzipped a
valid dbpedia.solrindex.zip file at location ${basedir}/target/indexes ) ..
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.apache.stanbol.entityhub.yard.solr.SolrYardTest
15:20:46,914 INFO SolrYardTest:77 - Test Solr Server Directory:
${basedir}/target/indexes
15:20:47,217 WARN SolrConfig:148 - <indexDefaults> and <mainIndex>
configuration sections are deprecated (but still work). Please use
<indexConfig> instead.
15:20:49,122 INFO SolrYard:709 - ... initialise new SolrDirectory Index
with name dbpedia by using Index Configuration dbpedia
15:20:49,226 ERROR SolrYard:474 - Exception while checking SolrIndex
'dbpedia' on ManagedSolrServer 'default'!
java.lang.IllegalStateException: Unable to copy default configuration for
Solr Index dbpedia to the configured path
/Users/managgar/projects/stanbol/stanbol/entityhub/yard/solr/target/indexes/default
at
org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer.updateCore(StandaloneManagedSolrServer.java:498)
at
org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer.updateIndex(StandaloneManagedSolrServer.java:407)
at
org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer.createSolrIndex(StandaloneManagedSolrServer.java:249)
at
org.apache.stanbol.commons.solr.managed.standalone.DefaultStandaloneManagedSolrServerWrapper.createSolrIndex(DefaultStandaloneManagedSolrServerWrapper.java:60)
at
org.apache.stanbol.entityhub.yard.solr.impl.SolrYard.createSolrIndex(SolrYard.java:712)
....
....
....
at
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:166)
at
org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
at
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:101)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: org.apache.solr.common.SolrException: Invalid luceneMatchVersion
'LUCENE_42', valid values are: [LUCENE_20, LUCENE_21, LUCENE_22, LUCENE_23,
LUCENE_24, LUCENE_29, LUCENE_30, LUCENE_31, LUCENE_32, LUCENE_33,
LUCENE_34, LUCENE_35, LUCENE_36, LUCENE_CURRENT] or a string in format 'V.V'
at org.apache.solr.core.Config.parseLuceneVersionString(Config.java:353)
at org.apache.solr.core.Config.getLuceneVersion(Config.java:337)
at org.apache.solr.core.SolrConfig.<init>(SolrConfig.java:140)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:452)
at
org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer.registerCore(StandaloneManagedSolrServer.java:464)
at
org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer.updateCore(StandaloneManagedSolrServer.java:495)
... 29 more
Caused by: java.lang.IllegalArgumentException: No enum const class
org.apache.lucene.util.Version.LUCENE_42
at java.lang.Enum.valueOf(Enum.java:196)
at org.apache.lucene.util.Version.valueOf(Version.java:33)
at org.apache.solr.core.Config.parseLuceneVersionString(Config.java:351)
... 34 more
15:20:49,230 INFO SolrYard:478 - Activated SolrYard testYard
Tests in error:
testFieldQuery(org.apache.stanbol.entityhub.yard.solr.SolrYardTest):
Unable to copy default configuration for Solr Index dbpedia to the
configured path
/Users/managgar/projects/stanbol/stanbol/entityhub/yard/solr/target/indexes/default
testStoreRepresentation(org.apache.stanbol.entityhub.yard.solr.SolrYardTest):
Unable to copy default configuration for Solr Index dbpedia to the
configured path stanbol/entityhub/yard/solr/target/indexes/default
testStoreRepresentation(org.apache.stanbol.entityhub.yard.solr.SolrYardTest):
Unable to copy default configuration for Solr Index dbpedia to the
configured path stanbol/entityhub/yard/solr/target/indexes/default
...
...
What I am doing wrong? How to initialize a SolrYard with the existing
dbpedia index??
Thanks in advance!!
Regards,
Manish
On Wed, Jul 10, 2013 at 7:52 PM, Rupert Westenthaler <
[email protected]> wrote:
> Hi Manish,
>
> I think you need to use the full URI for rdfs:label. QNAME support is
> implemented on the RESTful service layer and not supported when using
> the Java API.
>
> So changing
>
> String field = NamespaceEnum.rdfs + "label";
>
> should solve your issue (assuming that the initialization with the
> dbpedia index was successful)
>
> best
> Rupert
>
> On Wed, Jul 10, 2013 at 4:00 PM, Manish Aggarwal <[email protected]>
> wrote:
> > Hi,
> >
> > I am trying to use the entityhub/yard/solr module to directly query the
> > dbpedia.solrindex.
> > I have unzipped the dbpedia.solrindex.zip file
> > in entityhub/yard/solr/target/indexes/default folder.
> >
> > And modified the Solryardtest.java as given below but unable to find any
> > results. Am I missing something?
> >
> >
> >
> > public static final String TEST_SOLR_CORE_NAME = "dbpedia";
> >
> >
> > @Test
> >
> > public void testFieldQuery() throws YardException {
> >
> > Yard yard = getYard();
> >
> > String field = "rdfs:label";
> >
> >
> > TextConstraint tc = new TextConstraint("Roger Federer",
> > PatternType.wildcard, false, "en");
> >
> > FieldQuery query = yard.getQueryFactory().createFieldQuery();
> >
> > query.addSelectedField(field);
> >
> > query.setOffset(0);
> >
> > query.setLimit(10);
> >
> > query.setConstraint(field, tc);
> >
> > QueryResultList<Representation> results = yard.find(query);
> >
> > Representation result;
> >
> > Iterator<Representation> it = results.iterator();
> >
> > log.info("Number of results: " + results.size());
> >
> > }
>
>
>
> --
> | Rupert Westenthaler [email protected]
> | Bodenlehenstraße 11 ++43-699-11108907
> | A-5500 Bischofshofen
>