Copied to clipboard

Flag this post as spam?

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


  • Simon 692 posts 1068 karma points
    Jun 04, 2016 @ 13:13
    Simon
    0

    Search Functionality in Umbraco

    Hi Guys,

    I am working on a website where I want to include a search functionality to search for property real estate, by price, by property type, by location etc..

    Now, I have such properties in database that I am importing though CMS import, around 2500 properties.

    The search that I am doing is a normal Search form which searches using LINQ statements such as Where proeprtyTypeID = 3423, for example and where price is between fromPrice and toPrice, etc...

    But iy may results to some slowness or delaying in getting data, even when properties become larger, at around 10000.

    Does someone has any idea how I can approach this even when I have the search functioanlity almost done, such as some optimization how I can query data etcc..?

    Thank you

    Appreciate any help.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 06, 2016 @ 08:56
    Ismail Mayat
    0

    Simon,

    Examine is your friend https://our.umbraco.org/Documentation/Reference/Searching/Examine/

    You will need to specifically look into the docs and particulary gatheringnode data event.

    I would also take a look at ezsearch project you could use that and update where required to meet your specific requirements https://our.umbraco.org/projects/website-utilities/ezsearch/

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 09:02
    Simon
    0

    Hi Ismail,

    Thanks for your reply.

    I was thinking about that.

    But I'm quire confused to can achieve what I want with Examine.

    For example, how can I convert the below to Examine Search Please?

    nodes = rootNode.Descendants(ConstantNames.PropertyDocumentAliasName).Where(x => propertyTypesIds.Contains(x.GetPropertyValue<Picker>(ConstantNames.PropertyTypeAliasName).PickedKeys.First()) && localitiesIds.Contains(x.GetPropertyValue<Picker>(ConstantNames.PropertyLocalityAliasName).PickedKeys.First()));
    

    Appreaciate any help!

    Thanks a lot.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 06, 2016 @ 09:07
    Ismail Mayat
    0

    Simon,

    The type Picker what is that? Also in your external index your data is already there so I would open it using luke (https://code.google.com/archive/p/luke/) then see how PropertyType and PropertyLocality are stored. Is it csv list of ids?

    Regards

    Ismail

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 09:11
    Simon
    0

    H Ismail,

    The Picker refers to nuPickers since the value is chosen using the typehead nuPickers.

    Then I am checking if my list contains the value chosen from the CMS.

    How can I covert it to Umbraco Examine Search?

    Thanks

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 06, 2016 @ 09:31
    Ismail Mayat
    0

    I suspect in the index the ids are in as csv list. So you will firstly need to use gathering node data event and put them into the index as space separated list then you can query on it.

    So something like:

    private readonly BaseSearchProvider _externalSearcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
    
     var criteria = _externalSearcher.CreateSearchCriteria(IndexTypes.Content);
    
            var query = criteria.NodeTypeAlias("YourDocType"); 
    
    query = query.GroupedOr.Field(ConstantNames.PropertyTypeAliasName, trimmedType,listofIds);
    

    Something along those lines you will have to look at the docs.

    Regards

    Ismail

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 09:33
    Simon
    0

    What do you mean by trimmedType

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 06, 2016 @ 09:37
    Dennis Aaen
    0

    Hi Simon,

    Perhaps you can get some inspiration by have a look at this starter kit developed by Warren.

    https://our.umbraco.org/projects/starter-kits/razor-estate-agents-starter-site/

    Hope this can help you further.

    /Dennis

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 06, 2016 @ 09:52
    Ismail Mayat
    0

    sorry ignore that as i copied it from something else just use listofids.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 06, 2016 @ 09:53
    Ismail Mayat
    0

    Dennis,

    There is no examine search in that one.

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 09:55
    Simon
    0

    Hi Ismail,

    And the listOfIds, can by just a List

    Right?

    Kind Regards

    Thanks

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 06, 2016 @ 10:05
    Ismail Mayat
    0

    Simon,

    Correct so in your case you would use propertyTypesIds and localitiesIds on the 2 fields you want to search on with a grouped or. So you will say get me all document type properties that have propertyTypeid 1 or 2 or 3 and localitiy ids 6 or 7 or 8 etc.

    Regards

    Ismail

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 10:19
    Simon
    0

    Great.

    I will try it out and let you know.

    Cheers for your help.

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 10:59
    Simon
    0

    Hi Ismail,

    I am trying like this:

    var searchquery = criteria.NodeTypeAlias(ConstantNames.PropertyDocumentAliasName).And().GroupedOr(ConstantNames.PropertyTypeAliasName, propertyTypesIds.ToArray());
    

    but the first parameter of the GroupedOr is expecting an IEnumberable of string, as field.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 06, 2016 @ 11:05
    Ismail Mayat
    0

    yup so put the field in list even though its only one

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 11:18
    Simon
    0

    Hi Ismail,

    I am doing like this:

    var propertyTypeFieldInList = new List<string> {ConstantNames.PropertyTypeAliasName};
                    var propertyLocalituFieldInList = new List<string> {ConstantNames.PropertyLocalityAliasName};
    
                    var searchquery = criteria.NodeTypeAlias(ConstantNames.PropertyDocumentAliasName).And().GroupedOr(propertyTypeFieldInList, propertyTypesIds.ToArray()).And().GroupedOr(propertyLocalituFieldInList, localitiesIds.ToArray());
                    var results = helper.TypedSearch(searchquery.Compile());
    

    but no results is being returned.

    any idea why please?

    Kind Regards.

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 11:27
    Simon
    0

    Hi Ismail,

    The PropertyType and PropertyLocality of of type typeHeadList of nuPickers,

    the query is not working because of nuPickers.

    Before I was doing like this to get the value:

    x.GetPropertyValue<Picker>(ConstantNames.PropertyTypeAliasName).PickedKeys.First()
    

    Any help please?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 06, 2016 @ 13:11
    Ismail Mayat
    0

    Simon,

    Just before you make search call namely line helper.TypedSearch can you do

    criteria.ToString()
    

    And paste that back. This will give you the generated query. Also as I suggested earlier you need to download luke and look inside your index to see how data is stored. You can also run that raw query in luke. I suspect you need to massage your data in the index so its searchable. At the moment its probably in as csv list and thus not tokenised you need to store it as space separated values.

    If you look at source code of ezsearch you can see how a csv value is stored as space separated. See https://github.com/mattbrailsford/ezSearch/blob/master/Src/Our.Umbraco.ezSearch/Web/UI/App_Code/ezSearchBoostrapper.cs line 37

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 15:21
    Simon
    0

    Hi Ismail,

    Sorry for asking again, but I cannot figure it out.

    So in my case, how should I implement it? Would I need place the ids comma seperated? And how would I get the Picked key from Lucene nuPickers value?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 06, 2016 @ 15:59
    Ismail Mayat
    0

    Simon,

    Did you download luke and look inside your index also did you try the query in luke. This will give you better idea of what you need todo. You an use gatheringnode data event and get the values strip the , and replace with space and add back into index.

    Take a look at the code in ezsearch that shows you how to implement gatheringnode data event. In that code he is stripping , from path values and inserting space. You need todo something similar for your location and property type values then you can search on them

    Regards

    Ismail

  • Simon 692 posts 1068 karma points
    Jun 06, 2016 @ 20:12
    Simon
    0

    How can I install Luke?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 07, 2016 @ 07:06
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies