0 Replies Latest reply on Jan 26, 2012 4:41 PM by KimJohn Quinn

    FullTextSearch using SQL2 and Filesystem connector does not find records

    KimJohn Quinn Newbie

      I am trying to build out a few test cases with Modeshape's full-text-search using a Filesystem connector to find file(s) containing specific content and it is not behaving as I would expected...

       

      I have a single text file located under a directory with a bunch of gibberish and the search terms I am testing against.

       

      No matter how I search the repository it returns zero results.  I believe my repository is setup correctly because I can find the node directly using 'getNode()' or simple sql statements like 'SELECT * FROM [nt:file]' which shows me the file in the results.

       

      NOTE: Previously, I could not get any languages to work (Search, XPath) but after I added the Tika text extractor they passed.  Now, I cannot get the SQL2 language to work properly...

       

      Thanks.

       

      KJQ

       

       

      Using 'SQL2' language (does not work):

      //Verify I can even see the node
      Node root = this.session.getRootNode();
      System.out.println(root.getName());
      Node child = root.getNode("sample.txt");
      System.out.println(child.getName());
      
      QueryManager queryMgr = this.session.getWorkspace().getQueryManager();
      
      String expression = "SELECT * FROM [nt:base] WHERE CONTAINS(., '*bar' )";
      String language = Query.JCR_SQL2;
      
      Query query = queryMgr.createQuery(expression, language);
      QueryResult results = query.execute();
      
      RowIterator rowIter = results.getRows();
      Assert.assertEquals(1, rowIter.getSize());
      

       

       

      Using 'Search' language (works after adding Tika text extractor to setup):

      QueryManager queryMgr = this.session.getWorkspace().getQueryManager();
      
      String expression = "customer";
      String language = QueryLanguage.SEARCH;
      
      Query query = queryMgr.createQuery(expression, language);
      QueryResult results = query.execute();
      
      RowIterator rowIter = results.getRows();
      Assert.assertEquals(1, rowIter.getSize());
      

       

       

      Using 'XPath' language (works after adding Tika text extractor to setup):

      QueryManager queryMgr = this.session.getWorkspace().getQueryManager();
      
      String expression = "//*[jcr:contains(., '*bar')]";
      String language = Query.XPATH;
      
      Query query = queryMgr.createQuery(expression, language);
      QueryResult results = query.execute();
      
      RowIterator rowIter = results.getRows();
      Assert.assertEquals(1, rowIter.getSize());