Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        /// <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
                });
            }
        }
Ejemplo n.º 4
0
 public bool CircumsphereContains(double[] point)
 {
     if (!InfiniteSimplice)
     {
         return(containConstraint.CircumsphereContains(point));
     }
     else
     {
         //check restricions
         //foreach facets verify restriction. It's only possible to have zero or one facet
         //if no facet is made. Always CircumHyperSphere contains the new point
         if (!Facets.Any())
         {
             return(true);
         }
         else
         {
             ISimpliceFacet f = Facets.Single();
             return(f.semiHyperSpaceMatch(point));
         }
     }
 }
Ejemplo n.º 5
0
 public bool HasFacets()
 {
     return(Facets != null && Facets.Any());
 }