Exemple #1
0
        /// <summary>
        /// Create a offset/limit parameters
        /// </summary>
        /// <param name="limit">Value of limit</param>
        /// <param name="page">Value of page</param>
        public static ISolrSearch <TDocument> Page <TDocument>(this ISolrSearch <TDocument> search, int limit, int page)
            where TDocument : IDocument
        {
            var parameterBuilder = search.GetBuilder();

            search.Add(parameterBuilder.Limit(limit));
            search.Add(parameterBuilder.Offset((page - 1) * limit));

            return(search);
        }
Exemple #2
0
        public void Setup()
        {
            var solrConnection = new Mock <ISolrConnection>();

            solrConnection.Setup(q => q.Get(new SecurityOptions(), It.IsAny <string>(), It.IsAny <string>())).Returns("json");

            var engine = new MockEngine();

            engine.Setup(q => q.GetService <ISolrConnection>()).Returns(solrConnection.Object);
            engine.Setup(q => q.GetService <IOffsetParameter <TestDocument> >()).Returns(new Mock <IOffsetParameter <TestDocument> >().Object);
            engine.Setup(q => q.GetService <ILimitParameter <TestDocument> >()).Returns(new Mock <ILimitParameter <TestDocument> >().Object);
            engine.Setup(q => q.GetService <ISystemParameter <TestDocument> >()).Returns(new Mock <ISystemParameter <TestDocument> >().Object);
            engine.Setup(q => q.GetService <ISearchParameterCollection <TestDocument> >()).Returns(new Mock <ISearchParameterCollection <TestDocument> >().Object);

            var options    = new DocumentCollectionOptions <TestDocument>();
            var parameters = new List <ISearchItem>();

            for (int i = 0; i < this.ElementsCount; i++)
            {
                var parameterMock = new Mock <ISearchParameter>();
                parameterMock.Setup(q => q.AllowMultipleInstances).Returns(true);

                parameters.Add(parameterMock.Object);
            }

            _solrSearch = new SolrSearch <TestDocument>(options, engine.Object);

            parameters.ForEach(item => _solrSearch.Add(item));
        }
Exemple #3
0
 /// <summary>
 /// Create a filter parameter
 /// </summary>
 /// <param name="expression">Expression used to find the property name</param>
 /// <param name="from">From value in a range filter</param>
 /// <param name="to">To value in a range filter</param>
 /// <param name="tagName">Tag name to use in facet excluding list</param>
 public static ISolrSearch <TDocument> Filter <TDocument, TValue>(this ISolrSearch <TDocument> search, Expression <Func <TDocument, object> > expression, TValue?from, TValue?to, string tagName = null)
     where TDocument : IDocument
     where TValue : struct
 {
     search.Add(search.GetBuilder().Filter(expression, from, to, tagName));
     return(search);
 }
Exemple #4
0
        /// <summary>
        /// Create a sort parameter
        /// </summary>
        /// <param name="ascendent">True to ascendent order, otherwise false</param>
        /// <param name="expressions">Expression used to find the property name</param>
        public static ISolrSearch <TDocument> Sort <TDocument>(this ISolrSearch <TDocument> search, bool ascendent, params Expression <Func <TDocument, object> >[] expressions)
            where TDocument : IDocument
        {
            foreach (var item in search.GetBuilder().Sort(ascendent, expressions))
            {
                search.Add(item);
            }

            return(search);
        }
Exemple #5
0
 /// <summary>
 /// Create a filter parameter
 /// </summary>
 /// <param name="value">Value of the filter</param>
 public static ISolrSearch <TDocument> Filter <TDocument>(this ISolrSearch <TDocument> search, ISearchParameterValue <TDocument> value)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().Filter(value));
     return(search);
 }
Exemple #6
0
 /// <summary>
 /// Create a fields parameter
 /// </summary>
 /// <param name="expressions">Expression used to find the property name</param>
 public static ISolrSearch <TDocument> Fields <TDocument>(this ISolrSearch <TDocument> search, params Expression <Func <TDocument, object> >[] expressions)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().Fields(expressions));
     return(search);
 }
Exemple #7
0
 /// <summary>
 /// Create a facet range parameter
 /// </summary>
 /// <param name="aliasName">Name of the alias added in the query</param>
 /// <param name="expression">Expression used to find the property name</param>
 /// <param name="gap">Size of each range bucket to make the facet</param>
 /// <param name="start">Lower bound to make the facet</param>
 /// <param name="end">Upper bound to make the facet</param>
 /// <param name="countBefore">Counts should also be computed for all records with field values lower then lower bound of the first range</param>
 /// <param name="countAfter">Counts should also be computed for all records with field values greater then the upper bound of the last range</param>
 /// <param name="sortType">Sort type of the result of the facet</param>
 /// <param name="excludes">List of tags to exclude in facet calculation</param>
 public static ISolrSearch <TDocument> FacetRange <TDocument>(this ISolrSearch <TDocument> search, string aliasName, Expression <Func <TDocument, object> > expression, string gap = null, string start = null, string end = null, bool countBefore = false, bool countAfter = false, FacetSortType?sortType = null, params string[] excludes)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().FacetRange(aliasName, expression, gap, start, end, countBefore, countAfter, sortType, excludes));
     return(search);
 }
Exemple #8
0
 /// <summary>
 /// Create a facet query parameter
 /// </summary>
 /// <param name="aliasName">Name of the alias added in the query</param>
 /// <param name="query">Query used to make the facet</param>
 /// <param name="sortType">Sort type of the result of the facet</param>
 /// <param name="excludes">List of tags to exclude in facet calculation</param>
 public static ISolrSearch <TDocument> FacetQuery <TDocument>(this ISolrSearch <TDocument> search, string aliasName, ISearchParameterValue <TDocument> query, FacetSortType?sortType = null, params string[] excludes)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().FacetQuery(aliasName, query, sortType, excludes));
     return(search);
 }
Exemple #9
0
 /// <summary>
 /// Create a boost parameter
 /// </summary>
 /// <param name="query">Query used to make boost</param>
 /// <param name="boostFunctionType">Boost type used in calculation. Default is BoostFunctionType.Boost</param>
 public static ISolrSearch <TDocument> Boost <TDocument>(this ISolrSearch <TDocument> search, ISearchParameterValue <TDocument> query, BoostFunctionType?boostFunctionType = null)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().Boost(query, boostFunctionType ?? BoostFunctionType.Boost));
     return(search);
 }
Exemple #10
0
 /// <summary>
 /// Create a any parameter
 /// </summary>
 /// <param name="name">Name of the parameter</param>
 /// <param name="value">Value of the parameter</param>
 public static ISolrSearch <TDocument> Any <TDocument>(this ISolrSearch <TDocument> search, string name, string value)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().Any(name, value));
     return(search);
 }
Exemple #11
0
 /// <summary>
 /// Create a query parameter
 /// </summary>
 /// <param name="expression">Expression used to find the property name</param>
 /// <param name="value">Value of the query</param>
 public static ISolrSearch <TDocument> Query <TDocument>(this ISolrSearch <TDocument> search, Expression <Func <TDocument, object> > expression, string value)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().Query(value));
     return(search);
 }
Exemple #12
0
 /// <summary>
 /// Create a facet field parameter
 /// </summary>
 /// <param name="expression">Expression used to find the property name</param>
 /// <param name="sortType">Sort type of the result of the facet</param>
 /// <param name="limit">Limit of itens in facet's result</param>
 /// <param name="excludes">List of tags to exclude in facet calculation</param>
 public static ISolrSearch <TDocument> FacetField <TDocument>(this ISolrSearch <TDocument> search, Expression <Func <TDocument, object> > expression, FacetSortType?sortType = null, int?limit = null, params string[] excludes)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().FacetField(expression, sortType, limit, excludes));
     return(search);
 }
Exemple #13
0
 /// <summary>
 /// Create a query parameter with "*:*"
 /// </summary>
 public static ISolrSearch <TDocument> QueryAll <TDocument>(this ISolrSearch <TDocument> search)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().Query(new QueryAll <TDocument>()));
     return(search);
 }
Exemple #14
0
 /// <summary>
 /// Create a minimum should match parameter
 /// </summary>
 /// <param name="expression">Expression used to make the mm parameter</param>
 public static ISolrSearch <TDocument> MinimumShouldMatch <TDocument>(this ISolrSearch <TDocument> search, string expression)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().MinimumShouldMatch(expression));
     return(search);
 }
Exemple #15
0
 /// <summary>
 /// Create a facet limit parameter
 /// </summary>
 /// <param name="value">Value of limit</param>
 public static ISolrSearch <TDocument> FacetLimit <TDocument>(this ISolrSearch <TDocument> search, int value)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().FacetLimit(value));
     return(search);
 }
Exemple #16
0
 /// <summary>
 /// Create a random sort parameter
 /// </summary>
 /// <param name="ascendent">True to ascendent order, otherwise false</param>
 /// <param name="expressions">Expression used to find the property name</param>
 public static ISolrSearch <TDocument> RandomSort <TDocument>(this ISolrSearch <TDocument> search, bool ascendent)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().RandomSort(ascendent));
     return(search);
 }
Exemple #17
0
 /// <summary>
 /// Create a sort parameter
 /// </summary>
 /// <param name="expression">Expression used to find the property name</param>
 /// <param name="ascendent">True to ascendent order, otherwise false</param>
 public static ISolrSearch <TDocument> Sort <TDocument>(this ISolrSearch <TDocument> search, Expression <Func <TDocument, object> > expression, bool ascendent)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().Sort(expression, ascendent));
     return(search);
 }
Exemple #18
0
 /// <summary>
 /// Create a filter parameter
 /// </summary>
 /// <param name="expression">Expression used to find the property name</param>
 /// <param name="value">Value of the filter</param>
 /// <param name="tagName">Tag name to use in facet excluding list</param>
 public static ISolrSearch <TDocument> Filter <TDocument>(this ISolrSearch <TDocument> search, Expression <Func <TDocument, object> > expression, string value, string tagName = null)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().Filter(expression, value, tagName));
     return(search);
 }
Exemple #19
0
 /// <summary>
 /// Create a query field parameter
 /// </summary>
 /// <param name="expression">Expression used to find the property name</param>
 /// <param name="functionType">Function used in the spatial filter</param>
 /// <param name="centerPoint">Center point to spatial filter</param>
 /// <param name="distance">Distance from the center point</param>
 public static ISolrSearch <TDocument> SpatialFilter <TDocument>(this ISolrSearch <TDocument> search, Expression <Func <TDocument, object> > expression, SolrSpatialFunctionType functionType, GeoCoordinate centerPoint, decimal distance)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().SpatialFilter(expression, functionType, centerPoint, distance));
     return(search);
 }
Exemple #20
0
 /// <summary>
 /// Create a query field parameter
 /// </summary>
 /// <param name="expression">Expression used to make the mm parameter</param>
 public static ISolrSearch <TDocument> QueryField <TDocument>(this ISolrSearch <TDocument> search, string expression)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().QueryField(expression));
     return(search);
 }
Exemple #21
0
 /// <summary>
 /// Create a query parameter
 /// </summary>
 /// <param name="value">Parameter to include in the query</param>
 public static ISolrSearch <TDocument> Query <TDocument>(this ISolrSearch <TDocument> search, string value)
     where TDocument : IDocument
 {
     search.Add(search.GetBuilder().Query(value));
     return(search);
 }