Hi, I am having an issue getting my query to return the excerpt from a binary
file.  The following is the query i'm using:

query:
"//*[(@jcr:primaryType = 'cwe:file') and jcr:contains(jcr:content,
'apple')]/rep:excerpt() order by @jcr:score desc"

java:
RowIterator rowIter = qresult.getRows();                
String[] columns = qresult.getColumnNames();
                
while(rowIter.hasNext()) {
        Row row = rowIter.nextRow();
        log.debug("**********text excerpt=" +
row.getValue("rep:excerpt(.)").getString());
}


output:

javax.jcr.ItemNotFoundException: rep:excerpt(.)
        at
org.apache.jackrabbit.core.query.lucene.RowIteratorImpl$RowImpl.getValue(RowIteratorImpl.java:291)
        at
org.bmpcoe.cwe5.service.impl.SearchServiceImpl.getSearchResults(SearchServiceImpl.java:110)
        at
org.bmpcoe.cwe5.service.SearchServiceTests.testGetSearchResults(SearchServiceTests.java:129)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at
org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at
org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
        at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:421)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:1245)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:814)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1657)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:764)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
        at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

workspace.xml:

<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
        
        
        
        
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
        </SearchIndex>

Now I tried using rep:excerpt(.) with the period in the parenthesis.  I have
also tried to put a specific property in the parenthesis, but i seem to get
a query error each time that seems like my syntax is wrong.  When i use only
rep:excerpt() without anything in the parenthesis, the query works but only
returns </ excerpt> with no text.  I am using Jackrabbit 1.3.  I have
already configured my workspace.xml to support highlighting as seen above. 
So my questions are:  

1) Am I correctly querying for the excerpt?
2) Can I put a property in the rep:excerpt(jcr:content) like so to return an
excerpt from the property I specify?
3)  Is this feature supported in the Jackrabbit version that I'm using?
4)  When I do get the excerpt working, I have to use the rowIterator to get
the excerpt.  If i want to get the nodes using the nodeIterator and get an
excerpt, do I have to use the rowIterator and nodeIterator together or is
there an easier way to get both without looping through 2 iterators?


Marcel Reutegger wrote:
> 
> Hi Alexandre,
> 
> Alexandre Martins wrote:
>> I´m trying to use the highlighting, but i dont know how can I take the
>> value... as a property?
>> element.getProperty("jcr:excerpt").getString()
> 
> please note that the prefix is wrong and that it is a function:
> 
> row.getProperty("rep:excerpt(.)").getString();
> 
>> Other question,
>> Where in a configuration file i need to put this line "
>> name="supportHighlighting" value="true"/>"?
> 
> The workspace.xml file in
> <your-repository-home-dir>/workspaces/<workspace-name>
> 
> Add it as a child of the SearchIndex element.
> 
> regards
>   marcel
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-Can-I-catch-the-%22excerpt%22-value-from-highlighting--tf3709100.html#a12093126
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Reply via email to