L'interrogation de Solr via Solrj: notions de base

Je suis en train de requête solr via solrj dans Eclipse.
J'ai essayé la dernière solrj wiki exemple:

import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams;

import java.net.MalformedURLException;

public class SolrQuery2 {
  public static void main(String[] args) throws MalformedURLException, SolrServerException {
    SolrServer solr = new CommonsHttpSolrServer("http://localhost:8080/solr");

    //http://localhost:8080/solr/select/?q=outside
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("qt", "/select");
    params.set("q", "outside");

    QueryResponse response = solr.query(params);
    System.out.println("response = " + response);
  }
}

Cependant, je ne peux pas sortir de cette erreur ne importe ce que je fais:

Exception in thread "main" java.lang.NoSuchMethodError: 
    org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

Ensuite, j'ai essayé le livre de cuisine exemple:

import java.util.Iterator;
import org.apache.solr.client.solrj.SolrQuery; //Error: The import org.apache.solr.client.solrj.SolrQuery conflicts with a type defined in the same file
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;

public class SolrQuery {

      public static void main(String[] args) throws Exception {

          CommonsHttpSolrServer server = new CommonsHttpSolrServer("http://localhost:8080/solr");
          server.setParser(new XMLResponseParser());
          SolrQuery query = new SolrQuery();
          query.setQuery("document"); //Error: The method setQuery(String) is undefined for the type SolrQuery
          query.setStart(0); //Error: The method setStart(int) is undefined for the type SolrQuery
          query.setRows(10); //Error: The method setRows(int) is undefined for the type SolrQuery
          QueryResponse response = server.query(query); //Error: The method query(SolrParams) in the type SolrServer is not applicable for the arguments (SolrQuery)
          SolrDocumentList documents = response.getResults();
          Iterator<SolrDocument> itr = documents.iterator();
          System.out.println("DOCUMENTS");
          while(itr.hasNext()){
              SolrDocument doc = itr.next();
              System.out.println(doc.getFieldValue("id")+":"+doc.getFieldValue("content"));
          }

      }
    }

Cependant, cet exemple pourrait être daté de l'api actuelle que je ne peux même pas importer le SolrQuery de la bibliothèque.

Quelqu'un rapide standard exemple qui fonctionne?

Vous en remercie d'avance.

PS. Je suis sous windows7 avec tomcat7 et solr 3.5. Tout ce que je suis en train de faire à ce stade est une requête de base et d'obtenir les résultats dans une sorte de liste, tableau, que ce soit. Quand j'ai une requête: http://localhost:8080/solr/select/?q=outside dans firefox, les résultats de revenir très bien.

InformationsquelleAutor Chris | 2012-04-21