*I have a trouble concerning  SLIDE-LUCENE  search (full  text search)

first here is my code
*
reservation = acquireLock(_documentsRootPath,SHARED_LOCK); // début de la transaction
     namespace.begin();
     String grammarNamespace = searchRequestElement.getNamespaceURI();
     SearchQuery searchQuery
        = searcher.createSearchQuery (grammarNamespace,
                                      searchRequestElement,
                                      _slideToken,
java.lang.Integer.MAX_VALUE, // INFINITY
                                      "/slide"+ DEFAULT_DOCUMENTS_PATH);
org.apache.slide.search.SearchQueryResult queryResult = searcher.search(_slideToken, searchQuery);
     Iterator it = queryResult.iterator();
     while (it.hasNext()) {
       RequestedResource resource = (RequestedResource)it.next();



* Here I have no way to find which version of resource ( target file) complete the "searchQuery" !! in my test I have several versions of the same file and I don't which version is the good one : the itérator return one resource, even if, there is several versions of the same file which complete the query.


Regards


B DOREL
*

/**
   * Recherche full text sur l'index documentaire 
   * 
   * @param    int        index du document
   * @param    String     requête
   * @return   
   * @see sas.slideAPI.commun.corba.GestionDeContenuOperations
   *                  #rechercheFullTexte(int index, String requete)
   */
  public String rechercheFullTexte(
                    int index, 
                    String requete) throws SlideAPIException {
    long reservation = -1;
    try {
     // org.jdom.Element searchRequestElement = getQueryElement(requete);
     
      java.lang.StringBuffer sb = new StringBuffer(1024);
      sb.append("<D:searchrequest xmlns:D=\"DAV:\">"); //$NON-NLS-1$);
      sb.append("<D:basicsearch>");  //$NON-NLS-1$
      sb.append("<D:select>");       //$NON-NLS-1$
      sb.append("<D:prop>");         // à voir /> //$NON-NLS-1$
      sb.append("</D:prop>");        //$NON-NLS-1$
      sb.append("</D:select>");      //$NON-NLS-1$
      sb.append("<D:from>");         //$NON-NLS-1$
      sb.append("<D:scope>");        //$NON-NLS-1$
      sb.append("<D:href></D:href>");//$NON-NLS-1$
      sb.append("<D:depth>infinity</D:depth>");  //$NON-NLS-1$
      sb.append("</D:scope>");       //$NON-NLS-1$
      sb.append("</D:from>");        //$NON-NLS-1$
      sb.append("<D:where>");        //$NON-NLS-1$
      sb.append("<D:and>");          //$NON-NLS-1$
      sb.append("<D:contains>" + "Suppression" + "</D:contains>");
      sb.append("</D:and>");         //$NON-NLS-1$
      sb.append("</D:where>");       //$NON-NLS-1$
      sb.append("</D:basicsearch>"); //$NON-NLS-1$
      sb.append("</D:searchrequest>"); //$NON-NLS-1$
      
      org.jdom.Element searchRequestElement = getQueryElement(sb.toString());
     /*
      try
      {
        // récupérer la directory sans la créer !
          Directory dir = FSDirectory.getDirectory(DEFAULT_INDEX_ROOT_PATH, 
false);
          
          IndexSearcher searcher = new IndexSearcher(dir);
          Analyzer analyzer = new 
org.apache.lucene.analysis.standard.StandardAnalyzer();
          QueryParser qp = new QueryParser(Index.CONTENT_FIELD_NAME, analyzer);
          qp.setLowercaseExpandedTerms(true);
          Query query = qp.parse("Suppression");
          Hits hits = searcher.search (query);
          int noOfHits = hits.length();
          System.out.println("Nombre de docs : " + hits.length());
          for (int i = 0; i < noOfHits; i++)
          {
              org.apache.lucene.document.Document doc = hits.doc(i);
              String uri = doc.get(Index.URI_FIELD_NAME);
              System.out.println(uri );
          }
      }
      catch (Exception e)
      {
          throw new SearchException (e);
      }

      */
     
        
      reservation = acquireLock(_documentsRootPath,SHARED_LOCK);
        
      // début de la transaction
      namespace.begin();
      String grammarNamespace = searchRequestElement.getNamespaceURI();
      SearchQuery searchQuery 
         = searcher.createSearchQuery (grammarNamespace,
                                       searchRequestElement,
                                       _slideToken,
                                       java.lang.Integer.MAX_VALUE,     // 
INFINITY
                                 /*      new ComputedPropertyProvider(
                                                        namespace,
                                                        _slideToken, 
                                                        "/slide",
                                                        
(WebdavServletConfig)null),*/
                                       "/slide"+ DEFAULT_DOCUMENTS_PATH);
      
      org.apache.slide.search.SearchQueryResult queryResult = 
                                                 searcher.search(_slideToken, 
searchQuery);
      Iterator it = queryResult.iterator();
      while (it.hasNext()) {
        RequestedResource resource = (RequestedResource)it.next();
        NodeRevisionDescriptors nds = content.retrieve(_slideToken, 
resource.getUri());
        System.out.println(resource.getUri());
        for(Iterator i = resource.getAllProperties();
            i.hasNext();
            System.out.println(i.next()));
      }
      
    } catch (Throwable err) {
      // TODO Auto-generated catch block
      err.printStackTrace();
      throw new SlideAPIException(404 , "Erreur "+ requete + err);
    }finally{
      // finir la transaction 
      try {
        this.namespace.rollback();
      }catch (Exception ex){
        Domain.log("ERREUR   " + ex , LOG_CHANNEL, Logger.WARNING);
      }
      // QQA lacher le verrou 
      if(reservation != -1){
        releaseLock(reservation);
      }
    }
    
    return "";
  }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to