Copied to clipboard

Flag this post as spam?

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


  • Niclas Schumacher 67 posts 87 karma points
    Sep 27, 2013 @ 13:54
    Niclas Schumacher
    0

    examine search only in subsites

    Hallo guys.. 
    Im creating searchfunctionality on a site with alot of subsites and (maybe)redunant data on these different sites. The costumer would like to have a search on each subsite only searching in the nodes on these sites. There are quite a few sites, and they all have the same type of stucture, so the only difference is the content. 
    I would like to do all this with the same indexer. And i have an ideer to how i should do it, but if it is the right one or how to execute it properly that im not confident about : 

    My idear would be to create GatheringNodeDataHandler that finds the node subsite name, and stores it along the node. So when i want to search, i can specify that i only want to find results with that specefic subsitename in the field i set at Indexing. 
    To include this GatheringNodeDataHandler, should i just import the bin file into the project, and then it hooks up, or ?

     

    Best regards Niclas Schumacher

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Sep 27, 2013 @ 14:02
    Ismail Mayat
    0

    Niclas,

    Using gathering node data create a searchable path. You have path already in the index but its stored as csv and its not tokenised. So create new field call it whatever you like e.g searchablePath but replace the , with a space. Then when doing your search you look at the current page you are on and get its subsite parent id so lets say you have UK subsite and the uk homepage id is 1050. Make that id part of the search on searchable path so it will only get all pages which have that subsite home page as parent thus ignoring all other subsites. You can do it your way as well.

    Tips on how to implement gatheringnodedata can be found at http://thecogworks.co.uk/blog/posts/2012/november/examiness-hints-and-tips-from-the-trenches-part-2/ in fact it talks about searchable path there.

    Regards

    Ismail

  • Niclas Schumacher 67 posts 87 karma points
    Sep 27, 2013 @ 14:56
    Niclas Schumacher
    0

    Ismail, 

    Looks alot like the solution i thought of! Though, i didnt know that path was the equal to the parent id's(havn't worked that much with umbraco itself), and it seems like a great solution to the issue! 
    you, once agian, saved my day!
    Ill try to implement it, shouldn't be that big of a problem.
    - Have a great weekend! 

  • Niclas Schumacher 67 posts 87 karma points
    Oct 01, 2013 @ 12:10
    Niclas Schumacher
    0

    Ismail , 

    I made it how to said so, but.. I can't seem to get the result of only getting document which as that id in Searchablepath AND a search for the giving information. Here is my code.. 

     var q = searchCriteria.Field("searchablePath", parentNode.Id.ToString()).And().

    Field("bestGuess", searchString.Fuzzy().Value.Boost(20))

    .Or().GroupedOr(new string[] { "bodyText", "Borger", "nodeName" }, searchString.Split(' '))

    .Or().Field("keyWords", searchString.Fuzzy().Value.Boost(5))

    .Compile();

     

    How should i modify it to only get where parentNode.Id.Tostring() is in searchablePath ? And then search bestGuess and so on .. 

     

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 01, 2013 @ 12:22
    Ismail Mayat
    0

    Niclas,

    Can you write out the generated lucene query if you do searchCriteria.ToString() after the search is performed it should give you a query. Also can you double check in your index that you have the searchablePath field in with , replaced with space.

    Regards

    Ismail

  • Niclas Schumacher 67 posts 87 karma points
    Oct 01, 2013 @ 12:37
    Niclas Schumacher
    0

    { SearchIndexType: , LuceneQuery: searchablePath:1049 +bestGuess:arbejde^20.0 (bodyText:arbejde Borger:arbejde nodeName:arbejde) keyWords:arbejde^5.0 }

     

    in the searchablePath field, they are stored as singles, 14957 - 1051 etc etc.. So they are splitted on the ´,´ .

     

    Just se explain what i want to get out. Is all searchresults which has 1049 in searchablepath(they are children of that specefic node), together which search for "arbejde" in bestguess with boost, and bodyText, Broger, Nodename. And as last, keyWords with minor boost. 

    If you have any optimization for this, ill be glad to hear :) 

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 01, 2013 @ 12:41
    Ismail Mayat
    0

    Niclas,

    Can you try and run the query in luke or examine inspector see if you get any results. Also try wildcarding the searchable path

    parentNode.Id.ToString().MultipleWildcard()
    

    Its something like that. This will make your path query 1049*

    If that does not work try in luke just doing searchablePath:1049* see if that works. If it does then you need to fine tune the rest of the query.

    Regards

    Ismail

  • Niclas Schumacher 67 posts 87 karma points
    Oct 01, 2013 @ 12:46
    Niclas Schumacher
    0

    when i search for " searchablePath:1049 " in examine inspector, i get results back, though only the doc.id for some reason. 

     

    I have used BooleanOperation.Or, but it shouldn't do a difference, should it ? 

    var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 01, 2013 @ 12:59
    Ismail Mayat
    0

    in examine inspector which analyser are you using? Also in your website query just do and search on path and nothing else. I suspect its either analyser or the other bits added onto your query.

    Regards

    Ismail

  • Niclas Schumacher 67 posts 87 karma points
    Oct 01, 2013 @ 13:01
    Niclas Schumacher
    0

    I just figured something out, though i don't know how so solve it. 

    if i have the query :  searchablePath:1049 bestGuess:arbejde^20.0   (bodyText:arbejde Borger:arbejde nodeName:arbejde) keyWords:arbejde^5.0  

    I searched fine, though i findes 1180 documents.

    if i have the query:  bestGuess:arbejde^20.0   (bodyText:arbejde Borger:arbejde nodeName:arbejde) keyWords:arbejde^5.0 

    I get a 100 documents.. 

    So what i still want do achieve somehow, is getting the part of the 100 documents, where they have searchablePath: 1049. Instead of just having those 100 document retarded highest in the 1180 document.  

  • Niclas Schumacher 67 posts 87 karma points
    Oct 01, 2013 @ 13:07
    Niclas Schumacher
    0

    as i can see it it get a query like this, " Find everything which contains searchablePath = 1049, AND BestGuess = arbejde. And atm BestGuess isn't filled in any document, except a few for test. But then it should be balance on the other fields. it shouldn't be a MUST bestguess is set. And this comes because i write the And().

     

    When searcing only on the 1049 on the website, i get alot of results, i assume its the 1180..

Please Sign in or register to post replies

Write your reply to:

Draft