November Happy Hour will be moved to Thursday December 5th.

EPiServer Search not giving results for certain items

Vote:
 

Hi!

I have a page structure like this:

Products
   Productcategory
      Productlist
         Product
         Product

Some times, there are multiple productcategories, like this:

Products
   Productcategory
       Productcategory
           Productlist
              Product
              Product

 

On the productlist page I have a search function, that search the product children. It gives no result for the products with multiple productcategories. I can't see any other differences between the two cases. The first one gives results as excpected. The root in the code below is set to the productlist page.

var contentRootQuery = new VirtualPathQuery();
contentRootQuery.AddContentNodes(root);
typeQueries.QueryExpressions.Add(contentRootQuery);

I'm banging my head against the wall.....any ideas?

#171551
Nov 10, 2016 14:23
Vote:
 

If I set the root to be the top productcategory, it finds the products.

#171581
Nov 11, 2016 10:50
Vote:
 

Hi, Torrunn,

There shouldn't be any issues around the structure you have listed that would affect the search. I would rather think that the issue might be the result of the other query expressions.

Have you tried to exclude all other query expressions and search just with the root set to the category page in question? Does it still return 0 items?

BR,

Marija

#171608
Nov 12, 2016 9:46
Vote:
 

Hi, Marija

I tried to strip down the search expression to this:

private static int MaxResult = 100;

var query = CreateQuery(searchText, searchRoots, context, languageBranch);

private IQueryExpression CreateQuery(string searchText, IEnumerable<ContentReference> searchRoots, HttpContextBase context, string languageBranch)
        {

var query = new GroupQuery(LuceneOperator.AND);
query.QueryExpressions.Add(new FieldQuery(searchText));
foreach (var root in searchRoots)
            {
                var contentRootQuery = new VirtualPathQuery();
                contentRootQuery.AddContentNodes(root);
                query.QueryExpressions.Add(contentRootQuery);
            }
return query;
}

return _searchHandler.GetSearchResults(query, 1, MaxResult);

The root is set to the productlist page, but gives no results.

#171626
Nov 14, 2016 8:31
Vote:
 

Hi, Torunn,

If you are not sending in multiple search roots, the query should definitely work. If not so, you need another OR query:

            var typeQueries = new GroupQuery(LuceneOperator.OR);

            query.QueryExpressions.Add(typeQueries);

            foreach (var root in searchRoots)
            {
                var contentRootQuery = new VirtualPathQuery();
                contentRootQuery.AddContentNodes(root);
                typeQueries.QueryExpressions.Add(contentRootQuery);
            }

If you are sending one search root and not getting any results, might be that the index is corrupt. I'd try deleting and rebuilding it, if possible, just to rule that out.

BR,
Marija

#171663
Nov 14, 2016 17:12
Vote:
 

If neither helps, then it might be worth contacting Episerver support giving them the source code and DB, then they can troubleshoot further.

#171665
Nov 14, 2016 17:19
Vote:
 

Hi,

I'm only passing one root, and I have tried to reeindex. Do you know if there is any other way to delete the index than to check the checkbox for delete content, when using the "Admin/IndexContent.aspx" function?

#171698
Nov 15, 2016 13:32
Vote:
 

You can stop the site, delete the contents of the index folder, then start the site again and click Reindex under IndexContent.aspx.

#171699
Nov 15, 2016 13:38
Vote:
 

This didn't help either. Thanks for the help anyway:)

#171703
Nov 15, 2016 14:42
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.