public void PerformSearch(MultiFacetRequest request) { using (var multiSearcher = new FacetSearcher(Searcher.IndexReader, request.Config)) { if (request.Sort.Any() == true) { var collector = TopFieldCollector.Create( new Sort(request.Sort.ToArray()), request.MaxResults, false, false, false, false); multiSearcher.Search(request.Query, collector); _scoreDocs = collector.TopDocs().ScoreDocs; } else { var collector = TopScoreDocCollector.Create(request.MaxResults, true); multiSearcher.Search(request.Query, collector); _scoreDocs = collector.TopDocs().ScoreDocs; } var results = multiSearcher.SearchWithFacets(request.Query, request.MaxResults, request.Facets); foreach (var facet in results.Facets.GroupBy(x => x.FacetFieldName)) { Facets.Add(facet.Key, CreateFacetResult(facet.ToList())); } TotalItemCount = results.Hits.TotalHits; } }
public SearchFacetsViewModel(MessageBus messageBus) { MessageBus = messageBus ?? throw new ArgumentNullException("messageBus"); MessageBus.Subscribe <ServerSettingsChangedMessage>(m => { if (m.ServiceModel == null) { SelectedFacets.Clear(); Facets.Clear(); } }); MessageBus.Subscribe <BuildSearchMessage>(m => { SelectedFacets = Facets.SelectMany(f => f.Values).Where(v => v.Selected).ToList(); // save selected facets SelectedFacets.ForEach(v => m.Query.AddFacetValue(v.FacetName, v.ValueName)); // add facets to query }); MessageBus.Subscribe <EndSearchMessage>(m => { if (m.Results.ReturnOptions.HasFlag(ReturnOptions.Facets)) { Facets.Clear(); foreach (var facet in m.Results.Facets.Values) { var viewModel = new FacetViewModel(facet); viewModel.Values.ToList().ForEach(fv => fv.Selected = SelectedFacets.Any(sf => sf.Equals(fv))); Facets.Add(viewModel); } } }); Facets = new ObservableCollection <FacetViewModel>(); SelectedFacets = new List <FacetValueViewModel>(); }
/// <summary> /// Will indicate that the search results should return facet information for the given field. /// </summary> /// <param name="fieldName"></param> public void AddFieldFacet(string fieldName) { Verify.ArgumentNotNullOrEmpty(fieldName, nameof(fieldName)); if (Facets.Any(f => f.Key == fieldName)) { return; } var field = SearchDocumentBuilder.GetDefaultDocumentFields() .FirstOrDefault(f => f.Name == fieldName); if (field == null) { field = SearchFacade.DocumentSources.SelectMany(f => f.CustomFields) .FirstOrDefault(f => f.Name == fieldName); Verify.IsNotNull(field, $"Failed to find a document field by name '{fieldName}'"); } Verify.IsNotNull(field.Facet, $"Faceted search is not enabled for the field '{fieldName}'"); Facets.Add(new KeyValuePair <string, DocumentFieldFacet>( fieldName, field.Facet)); }
/// <summary> /// Setup. /// </summary> /// <param name="bounds"></param> public void Setup(System.Drawing.RectangleF bounds) { Triangle.ResetIndex(); Facets.Clear(); Points.Clear(); Bounds = bounds; Vertex tl = new Vertex(Bounds.Left, Bounds.Top, 0); Vertex tr = new Vertex(Bounds.Right, Bounds.Top, 0); Vertex bl = new Vertex(Bounds.Left, Bounds.Bottom, 0); Vertex br = new Vertex(Bounds.Right, Bounds.Bottom, 0); Triangle t1 = new Triangle(); Triangle t2 = new Triangle(); t1.A = bl; t1.B = tr; t1.C = tl; t2.A = bl; t2.B = br; t2.C = tr; t1.AB = t2; t2.CA = t1; Facets.Add(t1); Facets.Add(t2); }
public TestParamsViewModel() { SourceLength = 100.1; TargetLength = 110; Facets.Add(new NotchFacetViewModel(0, 5, Adjustment)); Facets.Add(new NotchFacetViewModel(1, 5.1, Adjustment)); Facets.Add(new NotchFacetViewModel(3, 5.1, Adjustment)); Facets.Add(new NotchFacetViewModel(4, 5.1, Adjustment)); Facets.Add(new NotchFacetViewModel(5, 5.1, Adjustment)); }
internal XSSimpleTypeDefinition(XmlSchemaSimpleType simpleType) : this() { _type = simpleType; if (_type.Annotation is XmlSchemaAnnotation annotation) { _annotation = XMLSchemaSerializer.CreateXSAnnotation(annotation); _annotation.BindToContainer(RootContainer, this); } if (_type.Content is XmlSchemaSimpleTypeList typeList) { _variety = XSSimpleTypeVariety.List; if (typeList.ItemTypeName is XmlQualifiedName qualifiedName) { _itemTypeName = new XMLExpandedName(qualifiedName); } } else if (_type.Content is XmlSchemaSimpleTypeUnion typeUnion) { _variety = XSSimpleTypeVariety.Union; MemberTypeDefinitions.Inserted -= MemberTypeDefinitions_Inserted; foreach (XmlSchemaObject item in typeUnion.BaseTypes) { IXSComponent component = XMLSchemaSerializer.CreateInstance(item); component.BindToContainer(RootContainer, this); MemberTypeDefinitions.Add(component); Components.Add(component); } MemberTypeDefinitions.Inserted += MemberTypeDefinitions_Inserted; } else if (_type.Content is XmlSchemaSimpleTypeRestriction typeRestriction) { _variety = XSSimpleTypeVariety.Atomic; if (typeRestriction.BaseTypeName is XmlQualifiedName qualifiedName) { _baseTypeName = new XMLExpandedName(qualifiedName); } Facets.Inserted -= Facets_Inserted; foreach (XmlSchemaObject item in typeRestriction.Facets) { IXSComponent component = XMLSchemaSerializer.CreateInstance(item); component.BindToContainer(RootContainer, this); Facets.Add(component); Components.Add(component); } Facets.Inserted += Facets_Inserted; } }
internal void AddDefaultFieldFacet(string fieldName) { if (Facets.Any(f => f.Key == fieldName)) { return; } Facets.Add(new KeyValuePair <string, DocumentFieldFacet>( fieldName, SearchDocumentBuilder.GetDefaultDocumentFields() .Single(f => f.Name == fieldName) .Facet)); }
public void Regenerate(double sourceLength, double targetLength, IList <double> sourceFacetLengths) { SourceLength = sourceLength; TargetLength = targetLength; var totalAdjustment = Adjustment; Facets.Clear(); for (int i = 0; i < sourceFacetLengths.Count; i++) { Facets.Add(new NotchFacetViewModel(i, sourceFacetLengths[i], totalAdjustment)); } }
public void PerformSearch(BoboFacetRequest request) { using (var boboReader = BoboIndexReader.GetInstance(Searcher.IndexReader, request.FacetHandlers)) using (var browser = new BoboBrowser(boboReader)) { var results = browser.Browse(request.BrowseRequest); _browseHits = results.Hits; foreach (var facet in results.FacetMap) { Facets.Add(facet.Key, CreateFacetResult(facet.Value)); } TotalItemCount = results.NumHits; } }
public void AddDefaultFacetsIfMissing(List <string> additionalFacets) { var defaultFacets = new List <string> { "theme", "type", "organization" }; if (additionalFacets.Any()) { defaultFacets.AddRange(additionalFacets); } foreach (var defaultFacet in defaultFacets) { if (Facets.All(f => f.Name != defaultFacet)) { Facets.Add(new FacetParameter { Name = defaultFacet }); } } }
/// <summary> /// Will indicate that the search results should return facet information for the given field. /// </summary> /// <param name="fieldName"></param> /// <param name="values">The array of values that are required to appear in the search documents.</param> /// <param name="notValues">The array of values that are required not to appear in the search documents.</param> public void AddFieldFacet(string fieldName, string[] values, string[] notValues) { Verify.ArgumentNotNullOrEmpty(fieldName, nameof(fieldName)); if (Facets.Any(f => f.Key == fieldName)) { return; } var field = SearchDocumentBuilder.GetDefaultDocumentFields() .FirstOrDefault(f => f.Name == fieldName); if (field == null) { field = SearchFacade.DocumentSources.SelectMany(f => f.CustomFields) .FirstOrDefault(f => f.Name == fieldName); Verify.IsNotNull(field, $"Failed to find a document field by name '{fieldName}'"); } Verify.IsNotNull(field.Facet, $"Faceted search is not enabled for the field '{fieldName}'"); Facets.Add(new KeyValuePair <string, DocumentFieldFacet>( fieldName, field.Facet)); if ((values != null && values.Length > 0) || (notValues != null && notValues.Length > 0)) { Selection.Add(new SearchQuerySelection { FieldName = fieldName, Values = values, NotValues = notValues, Operation = field.Facet.FacetType == FacetType.SingleValue ? SearchQuerySelectionOperation.Or : SearchQuerySelectionOperation.And }); } }
/// <summary> /// Insert. /// </summary> /// <param name="v"></param> /// <param name="old"></param> protected void Insert(Vertex v, Triangle old) { // Avoid duplicates, if this facet contains v as a vertex, // just return. if ((old.A.X == v.X) && (old.A.Y == v.Y)) { return; } if ((old.B.X == v.X) && (old.B.Y == v.Y)) { return; } if ((old.C.X == v.X) && (old.C.Y == v.Y)) { return; } m_points.Add(v); // Split old into 3 triangles, // Because old is counter clockwise, when duplicated, // ab, bc, ca is counter clockwise. // By changing one point and keeping to the commutation, // they remain counter clockwise. Triangle ab = new Triangle(old); // contains old ab, v is new C. Triangle bc = new Triangle(old); // contains old bc, v is new A. Triangle ca = new Triangle(old); // contains old ca, v is new B. ab.C = v; bc.A = v; ca.B = v; // This also makes assigning the sides easy. ab.BC = bc; ab.CA = ca; bc.AB = ab; bc.CA = ca; ca.AB = ab; ca.BC = bc; // The existing trianges that share an edge with old, // now share an edge with one of the three new triangles. // Repair the existing. // One way of looking at it: // for (int j = 0; j < 3; j++) // { // if ((ab.AB != null) && (ab.AB.Edge(j) == old)) ab.AB.SetEdge(j, ab); // if ((bc.BC != null) && (bc.BC.Edge(j) == old)) bc.BC.SetEdge(j, bc); // if ((ca.CA != null) && (ca.CA.Edge(j) == old)) ca.CA.SetEdge(j, ca); // } // This is faster, null check is once per edge, and default logic // reduces the compares by one. Instead of 3*3*2 comparisons = 18, // Worst case is 3*3 = 9, Average is 2+3+3=8. Triangle[] ta = { ab.AB, bc.BC, ca.CA }; Triangle[] tb = { ab, bc, ca }; for (int j = 0; j < 3; j++) { if (ta[j] == null) { continue; } if (ta[j].Edge(0) == old) { ta[j].SetEdge(0, tb[j]); continue; } if (ta[j].Edge(1) == old) { ta[j].SetEdge(1, tb[j]); continue; } ta[j].SetEdge(2, tb[j]); } // Add the new, remove the old. Facets.Add(ab); Facets.Add(bc); Facets.Add(ca); Facets.Remove(old); // Check for 1st order flipping. // Triangle ab has neighbor ab.AB. // Depth of up to recursion deep. // Remember that due to commutators, same.same is outward, // same.different is inward. flipIfNeeded(ab, ab.AB, Recursion); flipIfNeeded(bc, bc.BC, Recursion); flipIfNeeded(ca, ca.CA, Recursion); return; }
/// <summary> /// Adds the specified facet. /// </summary> /// <param name="facet">The facet.</param> internal void Add(SearchFacet facet) { Facets.Add(facet); }
public LinqToSolrQuery AddFacet(LambdaExpression field) { Facets.Add(LinqToSolrFacet.Create(field)); return(this); }
public void CreateFacetOfOrganizationSeoName() { Facets.Add(new FacetParameter { Name = "organization_seo_lowercase", Value = OrganizationSeoName }); }
public void CreateFacetOfArea() { Facets.Add(new FacetParameter { Name = "area", Value = AreaCode }); }
/// <summary> /// Adds a facet to the <see cref="Facets"/> collection /// </summary> /// <param name="facet"></param> /// <returns></returns> public StatsParameters AddFacet(string facet) { Facets.Add(facet); return(this); }