Problem using full text search
kinson Sep 20, 2010 2:54 PMI am new to modeshape and interested in its capability. I am using the repository example and extended it to add a search function like the following:
public void query(String sourceName) throws Exception {
Session session = createSession(sourceName);
// Obtain the query manager for the session ...
QueryManager queryManager = session.getWorkspace().getQueryManager();
// Create a query object ...
String language = this.userInterface.getQueryLang();
String expression = this.userInterface.getQueryExpr();
Query query = queryManager.createQuery(expression,language);
// Execute the query and get the results ...
QueryResult result = query.execute();
// Iterate over the nodes in the results ...
javax.jcr.NodeIterator nodeIter = result.getNodes();
while ( nodeIter.hasNext() ) {
Node node = nodeIter.nextNode();
System.out.println("Found matching node: path = " + node.getPath());
}
// Or iterate over the rows in the results ...
String[] columnNames = result.getColumnNames();
RowIterator rowIter = result.getRows();
int count = 0;
while ( rowIter.hasNext() ) {
count++;
Row row = rowIter.nextRow();
// Iterate over the column values in each row ...
/* Value[] values = row.getValues();
for ( Value value : values ) {
System.out.println("Row:" + count + " Value:" + value.getString());
} */
// Or access the column values by name ...
for ( String columnName : columnNames ) {
Value value = row.getValue(columnName);
System.out.println("Row:" + count + " Column:" + columnName + " Value:" + value.getString());
}
}
// When finished, close the session ...
session.logout();
}
This is pretty much straight from the example in the documentation with the missing pieces substituted with println. It works fine if I use language as JCR-SQL2 and type a query like "select * from [nt:file] where 'jcr:createdBy'='Fred'". However, if I use language Search for full text search with an expression of 'Fred', it failed with the following error:
There has been an error processing your command
Requests of type "org.modeshape.graph.request.FullTextSearchRequest" are unsupported; actual request was to search the "default" workspace with "'Fred'"
org.modeshape.graph.request.InvalidRequestException: Requests of type "org.modeshape.graph.request.FullTextSearchRequest" are unsupported; actual request was to search the "default" workspace with "'Fred'"
at org.modeshape.graph.request.processor.RequestProcessor.processUnknownRequest(RequestProcessor.java:386)
at org.modeshape.graph.connector.map.MapRequestProcessor.process(MapRequestProcessor.java:559)
at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:255)
at org.modeshape.connector.store.jpa.model.simple.SimpleJpaConnection.execute(SimpleJpaConnection.java:127)
at org.modeshape.graph.connector.RepositoryConnectionPool$ConnectionWrapper.execute(RepositoryConnectionPool.java:1129)
at org.modeshape.graph.Graph.execute(Graph.java:283)
at org.modeshape.graph.Graph$5.process(Graph.java:226)
at org.modeshape.graph.request.RequestBuilder.search(RequestBuilder.java:669)
at org.modeshape.graph.Graph.search(Graph.java:2535)
at org.modeshape.jcr.RepositoryQueryManager$SelfContained.search(RepositoryQueryManager.java:378)
at org.modeshape.jcr.JcrQueryManager$SessionQueryContext.search(JcrQueryManager.java:1486)
at org.modeshape.jcr.query.JcrSearch.execute(JcrSearch.java:70)
at org.modeshape.example.repository.RepositoryClient.query(RepositoryClient.java:490)
at org.modeshape.example.repository.ConsoleInput.displayNavigationMenu(ConsoleInput.java:218)
at org.modeshape.example.repository.ConsoleInput$1.run(ConsoleInput.java:105)
at java.lang.Thread.run(Thread.java:619)
I tried using different sources (JPA Source, Filesystem Source) and received the same error. I must have missing some configuration but I just couldn't figure it out.