Exemple #1
0
        public IEnumerable <UserQuery> GetSimilarQueries(string query)
        {
            var userQuery = new BoostedSearchQuery(query);

            userQuery.AddField("QueryString", 1.0f);
            CheckQuery(userQuery);
            return(_repository.GetAll <UserQuery>(userQuery.Query, userQuery.SearchableFields, userQuery.BoostValues, MAX_SIMILAR_QUERIES_COUNT));
        }
Exemple #2
0
        public async Task <IHttpActionResult> GetProductsDefaultFields([FromUri] string query)
        //public async Task<IEnumerable<Product>> GetProductsDefaultFields([FromUri]string query)
        {
            BoostedSearchQuery searchQuery = new BoostedSearchQuery();

            searchQuery.AddField(DEFAULT_PRODUCT_NAME_FIELD, 1.0f)
            .AddField(DEFAULT_PRODUCT_BARCODE_FIELD, 1.0f);
            //.AddField(DEFAULT_PRODUCT_COMPOSITION_FIELD, 1.0f);
            searchQuery.Query = query;

            var products = await _searchService.SearchProductAsync(searchQuery);

            if (products.Any())
            {
                return(Ok(products));
            }
            else
            {
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent)));
            }
        }