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..?
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?
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.
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.
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.
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());
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.
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
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.
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/
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?
Appreaciate any help!
Thanks a lot.
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
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
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:
Something along those lines you will have to look at the docs.
Regards
Ismail
What do you mean by trimmedType
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
sorry ignore that as i copied it from something else just use listofids.
Dennis,
There is no examine search in that one.
Hi Ismail,
And the listOfIds, can by just a List
Right?
Kind Regards
Thanks
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
Great.
I will try it out and let you know.
Cheers for your help.
Hi Ismail,
I am trying like this:
but the first parameter of the GroupedOr is expecting an IEnumberable of string, as field.
yup so put the field in list even though its only one
Hi Ismail,
I am doing like this:
but no results is being returned.
any idea why please?
Kind Regards.
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:
Any help please?
Simon,
Just before you make search call namely line helper.TypedSearch can you do
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
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?
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
How can I install Luke?
http://stackoverflow.com/questions/12951549/how-to-run-lukelucene-tool
is working on a reply...
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.