There is a new release of SolrNet (in alpha at this moment), it is version 0.4.0.
New features
Solr 4.0 grouping (this used to be called "field collapsing", but was completely overhauled)
Solr 4.0 pivot faceting
SolrQueryByDistance (spatial search)
Support for ExtractingRequestHandler (i.e. document indexing, like MS Word, PDF, etc)
Rollback (it was implemented but missing in ISolrOperations)
CommitWithin and Overwrite parameters for document add
Mixed exclusive/inclusive range queries (Solr 4.0 only)
See here the release message from Maurico
(yacb) yet another coders blog
Friday, June 24, 2011
Wednesday, June 8, 2011
Pivot tables in SolrNet
Pivoting support is now available for SolrNet.
Here is an example how to use the pivot tables feature within Solr using SolrNet.
To use it download the current source code of SolrNet from github. (select the master branch)
Here is an example how to use the pivot tables feature within Solr using SolrNet.
To use it download the current source code of SolrNet from github. (select the master branch)
var url = "someurlwhereyoursolrisrunning"; Startup.Init<Model.doc>(url); var solr = ServiceLocator.Current.GetInstance(); //Create a facet Pivot Query var facetPivotQuery = new SolrFacetPivotQuery() { //Define 2 pivots, one for inStock subgrouped by cat and //one for manu_exact subgrouped by cat Fields = new[] { "inStock,cat", "manu_exact,cat" }, //Set the minCount to 1 MinCount = 1 }; //Create the facet parameters //Note that you can use pivotQueries together //with other facets queries var facetParams = new FacetParameters() { Queries = new[] { facetPivotQuery }, //Limit the amounts of pivotRows to 15 Limit = 15 }; var queryOptions = new QueryOptions(); queryOptions.Facet = facetParams; queryOptions.Rows = 0; var results = solr.Query("ipod", queryOptions); if (results.FacetPivots.Count > 0) { foreach (var pivotTable in results.FacetPivots) { Console.WriteLine(String.Format("Pivot {0}, has {1} childgroups", pivotTable.Key, pivotTable.Value.Count.ToString())); } }
Monday, June 6, 2011
SolrNet Grouping example
Grouping and Pivoting support is now available for SolrNet.
Here is an example how to use the grouping feature within SolrNet.
To use it download the current source code of SolrNet from github. (select the master branch)
Here is an example how to use the grouping feature within SolrNet.
To use it download the current source code of SolrNet from github. (select the master branch)
var url = "someurlwhereyoursolrisrunning"; Startup.Init<Model.doc>(url); var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Model.doc>>(); var groupingParams = new GroupingParameters(); //Set the output groups, this means the output will have 2 groups //one group for popularity and one for manu_exact //these two groups are not nested groupingParams.Fields = new[] { "popularity", "manu_exact" }; //Set the output format to grouped groupingParams.Format = GroupingFormat.Grouped; var queryOptions = new QueryOptions(); //Set count of how many groups you want to return queryOptions.Rows = 20; //Add the grouping parameters queryOptions.Grouping = groupingParams; //Set sorting of the groups on the field popularity queryOptions.OrderBy = new[] { new SortOrder("popularity", Order.DESC) }; //Execute the query var results = solr.Query("ipod", queryOptions); //Examine the results if (results.Grouping.Count > 0) { foreach (var group in results.Grouping) { Console.WriteLine(String.Format("Group {0}, has {1} subgroups", group.Key, group.Value.Groups.Count.ToString())); } }
Grouping and Pivoting in SolrNet
Subscribe to:
Posts (Atom)