public void Update() { var solrSearcher = new SolrSearcher("http://localhost:8983/solr/", Mode.ReadWrite); ISolrSearcher searcher = new SolrSearcherAdapter(solrSearcher); var updater = new SolrUpdater(solrSearcher); ISolrUpdater s = new SolrUpdaterAdapter(updater); var doc = new SolrIndexDocument(); s.PostToIndex(doc); s.Commit(); }
public void Query() { var solrSearcher = new SolrSearcher("http://localhost:8983/solr/", Mode.ReadWrite); ISolrSearcher searcher = new SolrSearcherAdapter(solrSearcher); var updater = new SolrUpdater(solrSearcher); ISolrUpdater s = new SolrUpdaterAdapter(updater); ISolrQueryBuilder qb = new SolrQueryBuilder(searcher); qb.Query = new Query(); var parameters = new List<QueryParameter>(); parameters.Add(new QueryParameter("price", "[500 TO 1000]")); var qp = new QueryParameterCollection("q", parameters); qb.Query.AddQueryParameters(qp, ParameterJoin.AND); var results = new SolrSearchResults(qb); Console.WriteLine(results.TotalResults); }