Hi Samual, i'm no expert, but from what I've seen jcr:like searches in stored fields. Therefor you probably need to increase the max field length in the search configuration. This is set to 10000 characters by default.
See [1] and take a look at the 'maxFieldLength' parameter. Keep in mind though that the higher you set this value, the bigger your Lucene index will get. [1]http://wiki.apache.org/jackrabbit/Search Regards, Jeroen On Mon, Mar 28, 2011 at 8:58 PM, Samuel Cox <[email protected]> wrote: > First, I just tried with Jackrabbit and got the same result. > Basically, using jcr:like as part of a xpath query is not working for > long string properties. I have the following Scala app written for > testing. I can port to Java if necessary.. > > import javax.jcr._ > import org.apache.jackrabbit.core.TransientRepository > > object Searcher { > def main(args: Array[String]): Unit = { > val repo = new TransientRepository(); > val session = repo.login(new SimpleCredentials("f", Array('p'))); > try { > > val root = session.getRootNode; > val node = root.addNode("anode"); > node.setProperty("ls", ("a" * 10000) + "bcd"); > node.setProperty("ss", "aaabcd"); > > session.save(); > > val searcher = new Searcher(session); > > // Expect this to return sequence with 1 element. > val res = searcher.xpath(".[jcr:like(@ss, \"%bc%\")]"); > println(res.size) // and it does > > // Expect this to return sequence with 1 element. > val res2 = searcher.xpath(".[jcr:like(@ls, \"%bc%\")]"); > println(res2.size) // but it does not > } finally { > session.logout(); > } > } > } > > import javax.jcr.{Node, NodeIterator, Session} > import javax.jcr.version.Version > import javax.jcr.query.Query.XPATH; > > /** > * A facade for querying Jackrabbit. > * > * @author scox > */ > class Searcher(session: Session) { > > implicit def nodeIter2Iter( > i: NodeIterator > ) = new Iterator[Node] { > def next = i.nextNode; > def hasNext = i.hasNext; > def remove = i.remove; > } > > > lazy val queryMgr = session.getWorkspace.getQueryManager > > def xpath(xpath: String): Seq[Node] = { > val query = queryMgr.createQuery(xpath, XPATH); > val result = query.execute; > val iter = result.getNodes; > iter.toSeq > } > } > > > On Mon, Mar 28, 2011 at 1:21 PM, Jeroen Reijn <[email protected]> > wrote: > > Hi Samuel, > > > > could you describe what is not working? As far as I know this should work > > for any string, but it might have to do with the query or the stored > values. > > > > Regards, > > > > Jeroen > > > > On Wed, Feb 23, 2011 at 4:40 PM, Samuel Cox <[email protected]> > wrote: > > > >> Hi, > >> > >> I have been operating under the assumption that I could use jcr:like > >> to in effect do a substring search across string properties. This > >> worked well for all my test cases. The problem is that the real data > >> has strings that are much longer than my test data (bad test data:). > >> Anyhow, should this not work for any length string? I realize the > >> performance is bad, but we don't anticipate this search crossing > >> thousands and thousands of nodes. > >> > >> Here is a sample xpath: > >> > >> > >> > jcr:system/jcr:versionStorage/_x0036_c/_x0038_6/cb/_x0036_c86cb58-74a9-4955-b4a5-6b19eb6469f2/_x0031_.14//pvsw:artifact[jcr:like(pvsw:data/@pvsw:contents, > >> '%EDI%')] > >> > >> I'm going to try upgrading to 1.6.4 now. > >> > >> Any help is greatly appreciated. > >> > > >
