Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 17, 2017 @ 13:52
    Paul Seal
    0

    Examine search is not working on my site

    Hi all I've used Examine a lot on different sites, but I can't get it to work on a site I'm working on. I just get no results whatsoever.

    Have you had this problem before?

    Can you help please?

    Thanks

    Paul

  • Damiaan 436 posts 1287 karma points MVP 3x c-trib
    Jan 17, 2017 @ 14:24
    Damiaan
    0

    Paul,

    Do you have messages in the log (app_data/logs)?

    Are your write permissions ok?

    Kind regards
    Damiaan

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 17, 2017 @ 16:43
    Paul Seal
    0

    Hi Damiaan There are no messages relating to the Examine Search in my logs. I've got all of the correct permissions set up. I even added 'Everyone' to have full permission in the App_Data folder. There are Examine index folders and files in there too.

    Kind regards

    Paul

  • Damiaan 436 posts 1287 karma points MVP 3x c-trib
    Jan 17, 2017 @ 18:36
    Damiaan
    0

    Searching the wrong index? Does the index contains items when using the "examine management" tab in de developer section?

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 17, 2017 @ 19:27
    Paul Seal
    0

    Yes I get search results using the search tools in examine management, lucene search.

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 17, 2017 @ 19:54
    Paul Seal
    0

    This is the exact code I am using. Please try and implement it and let me know why I'm doing wrong.

    http://www.codeshare.co.uk/blog/how-to-search-by-document-type-and-property-in-umbraco/

  • Damiaan 436 posts 1287 karma points MVP 3x c-trib
    Jan 17, 2017 @ 21:10
    Damiaan
    0

    I would not use the code from that article. :-) It has some practices like this one:

    private UmbracoHelper _uHelper { get { return new UmbracoHelper(UmbracoContext.Current); } }
    

    You already have a property "Umbraco" on the SurfaceController exposing an umbracohelper. So you don't need to create another copy of it.

    Also, you are using MemoryCache.Default. I have some doubts on that. E.g. why are you caching lucene results? Is you search so intensive? If you have a big site, with lot of seaches, you will be caching complete documents multiple times in memory for different searches. And last remark about using this: you are not using lock() to insert something into the cache. Have you considered the built-in CacheHelper?

    That being said, if you really want to use your code from your article, you should supply a littlebit more information on what exactly is not working.
    Do you have build errors or runtime errors? Do you have a stacktrace? If you are debugging, what line does return unexpected results? What do you see, and what not?

    Kind regards
    Damiaan

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 17, 2017 @ 21:15
    Paul Seal
    0

    Thanks for your points about caching. I just didn't think it needed to query again to get results for each page.

    I have this working on one site absolutely fine and it works a great. It's just when I put it on another site there are no results coming back. Are there some settings I need to turn on or change?

  • Damiaan 436 posts 1287 karma points MVP 3x c-trib
    Jan 17, 2017 @ 21:20
    Damiaan
    0

    Then you probably forgot something to copy.

    Do you have build errors or runtime errors? If so, do you have a stacktrace? If you are debugging, what line does return unexpected results? What do you see, and what not?

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 18, 2017 @ 08:36
    Paul Seal
    0

    I'm not getting any build or runtime errors. The search just comes back with no results.

    I took on board your feedback and changed the code, removing caching etc.

  • Ismail Mayat 4511 posts 10056 karma points MVP 2x admin c-trib
    Jan 18, 2017 @ 10:55
    Ismail Mayat
    0

    Paul,

    On you local machine step through with a debugger then at line:

     return ExamineManager.Instance.Search(queryNodes.Compile()); 
    

    Just before it do

    searchCriteria.ToString()
    

    This will give you the generated query, copy out of the only the lucene query bit then in Examine manager run that lucene query see if you get any results. Also may be try and open the index on the server using luke then try running the query in that.

    Regards

    Ismail

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 18, 2017 @ 14:32
    Paul Seal
    0

    Hi Ismail Thanks for this, how do I run the lucene query myself once I have copied it?

    Cheers

    Paul

  • Ismail Mayat 4511 posts 10056 karma points MVP 2x admin c-trib
    Jan 18, 2017 @ 14:46
    Ismail Mayat
    0

    Paul,

    you have two options 1, run the query in examine manager in the back office there is option to use lucene syntax you can then paste the query in there and run it.

    1. Download luke for lucene (https://code.google.com/archive/p/luke/downloads get v3.5.0) , you will need java as its written in java. Then you will need to open your index with that so either run luke on the machine that is not working or get a copy of the index then try opening it locally.

    Regards

    Ismail

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 18, 2017 @ 14:49
    Paul Seal
    0

    Thanks for the tip about getting the output of the search criteria and using Luke. I've managed to query my index using Luke. There are no results using the query which was outputted, but if I take some off I start to get results so I'm getting somewhere. Thank you.

  • Ismail Mayat 4511 posts 10056 karma points MVP 2x admin c-trib
    Jan 18, 2017 @ 14:57
    Ismail Mayat
    0

    I need to see the query can you paste it please.

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 18, 2017 @ 15:11
    Paul Seal
    0

    This is the query that is not working:

    +umbracoNaviHide:0 +(nodeTypeAlias:blogpost nodeTypeAlias:home nodeTypeAlias:landingpage nodeTypeAlias:textpage) +(content:home contents:home nodeName:home introduction:home siteDescription:home siteTitle:home)
    
  • Ismail Mayat 4511 posts 10056 karma points MVP 2x admin c-trib
    Jan 18, 2017 @ 17:44
    Ismail Mayat
    100

    The umbracoNaviHide:0 does not look right to me which is generated by code

     queryNodes = searchCriteria.Field(_hideField_propertyAlias, _hideField_value_false).Or().Field(_hideField_propertyAlias, _hideField_value_notSet);
    

    You need something like:

    examineQuery.Not().Field(_hideField_propertyAlias, 1.ToString());
    

    This will generate

    -umbracoNaviHide:1
    

    So you do not need that or stuff. In fact I am certain this is the issue looking at your code:

    private string _hideField_value_notSet { get { return ""; } }
    

    You cannot do this with lucene you. So in sql you can do

    select * from whatever where field=''

    See this post https://lists.gt.net/lucene/java-user/64663

    Lets say you have field called town. You want to pull back all documents in the index where town is empty. You cannot do as you are doing

    Or().Field(_hideField_propertyAlias, _hideField_value_notSet)
    

    You would have to use gathering node data event and then test if town is null or empty then inject in a blag value e.g emptyTown.

    Then you could do

    And.Field("town", "emptyTown");
    

    This would then get you all documents with town not set.

    Regards

    Ismail

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 19, 2017 @ 09:27
    Paul Seal
    0

    Thanks for your help. I was able to get it working by changing this line:

    queryNodes = searchCriteria.Field(_hideField_propertyAlias, _hideField_value_false).Or().Field(_hideField_propertyAlias, _hideField_value_notSet);
    

    with this line

    queryNodes = searchCriteria.GroupedNot(new string[] { "umbracoNaviHide" }, "1");
    
  • Ismail Mayat 4511 posts 10056 karma points MVP 2x admin c-trib
    Jan 19, 2017 @ 09:30
    Ismail Mayat
    1

    haha so it was the umbracoNaviHide.

  • Paul Seal 425 posts 2326 karma points MVP 3x c-trib
    Jan 19, 2017 @ 09:47
    Paul Seal
    0

    Yes, but the strange thing is it has worked on other sites.

    But thank you so much. You've helped me learn more about Examine.

    I love it, I write posts about things I've learned and I always end up learning more from others.

    h5yr

  • Ismail Mayat 4511 posts 10056 karma points MVP 2x admin c-trib
    Jan 19, 2017 @ 10:00
    Ismail Mayat
    0

    Paul,

    There is an official examine course due very soon. Covers alot of this kind of stuff.

    Regards

    Ismail

  • Jason D 14 posts 35 karma points
    Aug 28, 2020 @ 00:09
    Jason D
    0

    Paul,

    I ran into your blog post to create advanced search, and started implementing it, but ran into some (probably older) syntax, etc, that needed updated. I'm curious if you're planning on updating the post with code that'll work with Umbraco 8+?

    https://codeshare.co.uk/blog/how-to-search-by-document-type-and-property-in-umbraco/

    I'm getting close to wrapping up a custom .Net site into an Umbraco CMS instance, and the Predictive Search and Search functionality is where I'm at now. Currently, the site does sql calls to get products, pages, blog posts, etc, and puts them into repositories to use and theme out in both a predicitve results set and on the search page itself.

    Jason

Please Sign in or register to post replies

Write your reply to:

Draft