// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.Collections.Generic; using System.Linq; using SolrNet; using SolrNet.Commands.Parameters; namespace TextSearch.Solr.Mapped { public class Search { private static void Dump(ISolrOperations client, string query) { Console.WriteLine("search for : {0}", query); List> optparams = new List>(); optparams.Add(new KeyValuePair("df", "alltext")); QueryOptions options = new QueryOptions(); options.ExtraParams = optparams; List res = client.Query(query, options).ToList(); foreach (ChessOpening doc in res) { Console.WriteLine(" {0} - {1}", doc.Names, doc.Moves); } } public static void Main(string[] args) { ISolrOperations client = SolrNet.SolrNet.GetServer("http://localhost:8888/solr/chessopening", true); // all Dump(client, "*:*"); // one Dump(client, "names:defense"); Dump(client, "moves:d4"); // dual Dump(client, "alltext:defense"); Dump(client, "alltext:d4"); Dump(client, "defense"); // default field Dump(client, "d4"); // default field // boolean Dump(client, "names:defense moves:d4"); // implicit or Dump(client, "names:defense AND moves:d4"); // and Dump(client, "names:defense NOT moves:d4"); // not Dump(client, "defense d4"); // default field + implicit or Dump(client, "defense AND d4"); // default field + and Dump(client, "defense NOT d4"); // default field + not // wildcard Dump(client, "names:def*"); Dump(client, "moves:N*"); } } }