Copied to clipboard

Flag this post as spam?

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


  • Ryan Noble 17 posts 85 karma points
    Feb 27, 2017 @ 14:01
    Ryan Noble
    0

    Examine: Removing escaped characters and wildcards

    I've been attempting to create a examine ICriteria that uses path, however no matter what I try I cant get it to keep either wildcards or escaped '-'

    string path = "-1,1012,1020*";

    I have added trailing wildcards to the index, still doesnt work.

    I've manually forced the Lucene syntax it doesnt work, Hell I've made the search even look for the nodeTypeAlias and wont return results.

    I'm trying to have the search look at articles, under a certain section, with a certain set of tags, I have resolved the tags as a field in the index but it wont accept anything I send to it.

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Feb 28, 2017 @ 17:19
    Marc Goodson
    0

    Hi Ryan

    Have you tried adding an additional property to the index which is the path without the comma's ?

    eg

    -1 1012 1020

    You can read more in this quite old but still quite relevant blogpost from @attackmonkey...

    http://www.attackmonkey.co.uk/blog/2011/12/limiting-an-examine-search-to-the-current-site

    regards

    Marc

  • Ryan Noble 17 posts 85 karma points
    Mar 01, 2017 @ 09:42
    Ryan Noble
    0

    Its not the comma's thats an issue, its the "-" and the "*"

    Escaping the minus due to it meaning Not in lucene means adding a backslash, but backslash hyphen isnt a C# escape configuration so the escape the backslash for lucene you need another backslash but then when the raw query is put into the ICriteria the escaping backslash for the hyphen is still there.

    Alternatively using String builder I was able to leave just 1 backslash to escape the hyphen but then when it was put into the ICriteria it would strip both the hyphen and the asterisk wild card.

    I found that theres no way for a raw query to take those needed characters so I've had to run 4 seperate index searches.

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Mar 02, 2017 @ 09:10
    Marc Goodson
    0

    Hi Ryan

    I may be completely misunderstanding, but with the path seperated only by spaces in a SearchablePath field, then it's just a question of searching the index with the SearchablePath field containing the id of the section you want to limit to...

    So if you want to limit your search to the section with id 1012

    then it is enough that the SearchablePath field contains 1012, the spaces enable you to find the id anywhere in the path string, without having to do anything clever with wildcards!

    eg

    var searchTerm = "fish";
    var sectionId = 1012;
    
    var searcher = ExamineManager.Instance.SearchProviderCollection["myIndexSearcher"];
    
    var criteria = searcher.CreateSearchCriteria();
    Examine.SearchCriteria.IBooleanOperation filter = null;
    filter = criteria.GroupedOr(new string[] { "nodeName", "bodyText", "title" }, searchTerm);
    // filter by section
    filter.And().Field("searchablePath", sectionId);
    var results = searcher.Search(filter.Compile());
    

    but as I say, may be misunderstanding what your after.

    regards

    Marc

  • Ryan Noble 17 posts 85 karma points
    Mar 02, 2017 @ 11:12
    Ryan Noble
    0

    Hi marc, The issue has absolutely nothing to do with the commas.

    As I previously stated Its not the comma's thats an issue, its the "-" and the "*" characters that are being removed as my initial message outlined.

    There is no reason to add an additional index for an already existing field wen the only requirement is that 2 additional characters are being stripped by lucene even when following proper syntax of escaping and wildcards.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 02, 2017 @ 12:17
    Ismail Mayat
    1

    Ryan,

    For path queries i have always inject in new field without , then done query on the parent not full path. So you have

    string path = "-1,1012,1020*";
    

    I have done

    string path = "1020";

    and it works for me so i only get all docs that have parent 1020

    Regards

    Ismail

  • Tom Steer 161 posts 596 karma points
    Mar 02, 2017 @ 11:20
  • Ryan Noble 17 posts 85 karma points
    Mar 07, 2017 @ 08:53
    Ryan Noble
    0

    Hey guys, So the reason I need to have the full path string is because I'm not querying their direct parent, rather root node with a section where the content types sit, almost all of them dont have a direct parent for me to query without triplicating the resolves.

    Thanks tom,

    I've resolved using String builder to concat the query and place into a IBoolean object rather than an ICriteria Object.

    I've now run into an issue with the Range function not being able to use negative inputs.

    Find: -25.4564813

    Double min: -26.564648; Double max: -23.464648; Range("Latitude", min, max, true, true)

    Returns none but: Double min: 26.564648; Double max: 23.464648; Range("Latitude", min, max, true, true)

    Returns the right results with using the polar opposite range

  • Adam 8 posts 86 karma points
    Jun 27, 2019 @ 14:54
    Adam
    0

    I am pretty sure that, removal of escaped characters depends on Searcher configuration, I.e, when I user "ExternalSearcher" I had similar issue, but then when I moved to "InternalSearcher" didn`t had this issue any more.

Please Sign in or register to post replies

Write your reply to:

Draft