Creating advanced search functionality in Umbraco 7
Hi all,
I have a bit of a dilemma with a new project we are due to start in the coming weeks.
We require an advanced search that allows site visitors on the front end to search through a number of packages on products we have on the site based upon given criteria. The proposed search form can be seen below:
Each of these criteria relate to a property field within the document types to be searched and I was wondering what the best approach would be to produce this functionality or whether there is an existing search tool within Umbraco that could be used for these purposes (paid or free).
I am aware of how to produce a simple Rich-text based search in Umbraco however the documentation is somewhat lacking both on this forum and across the web as to how to perform more useful advanced search methods like the ones proposed above.
My main area of concern is the Departure Date and Date To fields as this will essential be a range. The dates that a product is available on will be stored in CSV format in an Umbraco field and this field will have to be parsed to not only find the date specified in the departure date but also the date to and any dates in between those specified.
Any help or guidance on this issue would be greatly appreciated as we have already been told we have to do this project in half the time we asked for and it is kind of getting to the wire right now.
Thanks for this but unfortunately the cost of that product is unreasonable in the scope of this project.
Furthermore, from the looks of things this requires or works with individual date facets. What we require is for multiple dates to be related to a particular page and for the search field to be displayed on the homepage linking the user to an actual search page.
Is it a lot of data? Sometimes I build a custom search without examine. For example just a linq query that searches some properies. With linq queries it's also easy to search between dates.
I did something similar ages ago see http://www.world-of-incentives.com/programme-ideas.aspx the search form on submission builds an examine query then does the search. One thing you will need todo is maybe massage some of the data so it can be searched you do this using gatheringnode data event. You will need to code this up, i am not aware of any package that will automagically do this for you. With the fields in your form that you have can you let me know what type they are and if they live in umbraco as nodes.
Thanks for your response.
In this case, we will have a page called a tour master. This is essentially all of the common details about a tour that runs on different dates. So for example, common details would be the name, the activities involved and the equipment required.
Within this tour master, rather than creating an individual page for each departure we will have a property called : departure dates which houses in CSV format (or XML or JSON whichever is best) the dates on which the tour departs.
So this property would contain something like this:
Then in our search form on the homepage they would be able to specify that they wish to search for tours that occur between:
Start Date: 12/12/2013
End Date: 18/12/2013
As the example above has dates that feature within this range:
(13/12/2013, 14/12/2013, 15/12/2013, 17/12/2013)
It should be returned to the search results page if it complies with the additional search criteria such as category that has been defined in the search form. Each tour can be assigned to multiple categories and is assigned via a property within the tour master that links it to one of the category pages.
Ouch, this has me a little stumped. I would maybe try the following,using gatheringnode data event get the csv list of dates and inject each one in new field so if i have 02/11/1988, 03/11/1988, 13/12/2013, 14/12/2013, 15/12/2013, 17/12/2013 that is six fields injected in like tour_date_1, tour_date_2 etc then do range query grouped or over those dates, although one problem will be knowing how many date fields to range over. Is there a max no of dates that a tour can occur on? I suspect not?
You may just try using Examine for the non-date search fields, the filter the Examine results by date. Another thing I've done on a project is put the month as a new field in the GatheringNodeData event. In this case, you could narrow the results to the correct month (and the other non-date fields), then post-process the resutls (which is a much smaller set).
Thanks for your replies.
I'm currently in the process of following this tutorial to setup examine and try and get some search results appearing based upon multiple fields in an older project (still Umbraco 7 though):
This appears to the successfully setup the temporary file under the path specified above however, when I try to rebuild this index from the Developer section is says that nothing has been indexed.
I'm also trying to run a simple query from a template page using the code provided in the tutorial above searching for 'BUE' which is a value I know features in one or more of my packages in the citycode property however I am getting an error in Visual Studio that:
Umbraco.Web.Models.RenderModel does not contain a definition for 'NodeById'
Okay so I think I've solved the NodeById bit and have used the following instead:
var node = Umbraco.Content(item.Fields["id"]);
However, my index is still returning 0 even when I rebuild it. Why is this happening?
I have checked the document type alias and it is definitely package so this should be working.
The document type alias is "package" as I always write my aliases lowercase. I have also checked this in the back office.
There are no code errors now (as I fixed these in my template as I mentioned above) however like I say, no pages are being indexed under the new MyIndex in the Umbraco backoffice despite there being a large number of pages with the "package" document type alias.
Just a wild guess, but maybe you can hook in to the documentwriting or gathering node data events to see if these get fired when you publish a "package"
To be honest I'm starting to think that Examine just doesn't work. I've followed official Umbraco tutorials and yet nothing is being indexed. How would I go about hooking into those as the documentation is somewhat lacking?
Try doing a manual search using the search tools at the bottom of the Examine Manager tab. It may help to print our the compiled Lucene query to the page to get the exact search.
I have tried doing just a manual text search in the search tools and nothing is returned. It's odd because I have had a look in Luke and the data is indexed in there as expected but when I try and run a Lucene query in Luke or in Umbraco nothing is returned.
Creating advanced search functionality in Umbraco 7
Hi all,
I have a bit of a dilemma with a new project we are due to start in the coming weeks.
We require an advanced search that allows site visitors on the front end to search through a number of packages on products we have on the site based upon given criteria. The proposed search form can be seen below:
Each of these criteria relate to a property field within the document types to be searched and I was wondering what the best approach would be to produce this functionality or whether there is an existing search tool within Umbraco that could be used for these purposes (paid or free).
I am aware of how to produce a simple Rich-text based search in Umbraco however the documentation is somewhat lacking both on this forum and across the web as to how to perform more useful advanced search methods like the ones proposed above.
My main area of concern is the Departure Date and Date To fields as this will essential be a range. The dates that a product is available on will be stored in CSV format in an Umbraco field and this field will have to be parsed to not only find the date specified in the departure date but also the date to and any dates in between those specified.
Any help or guidance on this issue would be greatly appreciated as we have already been told we have to do this project in half the time we asked for and it is kind of getting to the wire right now.
Hello,
I don't have any experience with this kind of search, but you could have a look at Xuntos Faced Search: https://www.xfssearch.com/
Jeroen
Hi Jeroen,
Thanks for this but unfortunately the cost of that product is unreasonable in the scope of this project. Furthermore, from the looks of things this requires or works with individual date facets. What we require is for multiple dates to be related to a particular page and for the search field to be displayed on the homepage linking the user to an actual search page.
Kind regards,
Jason Espin
Hello,
Is it a lot of data? Sometimes I build a custom search without examine. For example just a linq query that searches some properies. With linq queries it's also easy to search between dates.
Jeroen
Guys,
I did something similar ages ago see http://www.world-of-incentives.com/programme-ideas.aspx the search form on submission builds an examine query then does the search. One thing you will need todo is maybe massage some of the data so it can be searched you do this using gatheringnode data event. You will need to code this up, i am not aware of any package that will automagically do this for you. With the fields in your form that you have can you let me know what type they are and if they live in umbraco as nodes.
Regards
Ismail
Oh that reminds me i did something similar here http://www.thefabricofindustry.com/ and detailed in uhangout video how i did it see http://uhangout.co.uk/videos/ep006-with-ismail-mayat-a-walkthrough-of-a-site-powered-by-examine-searches/
Hi Ismail,
Thanks for your response. In this case, we will have a page called a tour master. This is essentially all of the common details about a tour that runs on different dates. So for example, common details would be the name, the activities involved and the equipment required.
Within this tour master, rather than creating an individual page for each departure we will have a property called : departure dates which houses in CSV format (or XML or JSON whichever is best) the dates on which the tour departs.
So this property would contain something like this:
02/11/1988, 03/11/1988, 13/12/2013, 14/12/2013, 15/12/2013, 17/12/2013
Then in our search form on the homepage they would be able to specify that they wish to search for tours that occur between:
Start Date: 12/12/2013
End Date: 18/12/2013
As the example above has dates that feature within this range:
(13/12/2013, 14/12/2013, 15/12/2013, 17/12/2013)
It should be returned to the search results page if it complies with the additional search criteria such as category that has been defined in the search form. Each tour can be assigned to multiple categories and is assigned via a property within the tour master that links it to one of the category pages.
Kind regards,
Jason Espin
Jason,
Ouch, this has me a little stumped. I would maybe try the following,using gatheringnode data event get the csv list of dates and inject each one in new field so if i have 02/11/1988, 03/11/1988, 13/12/2013, 14/12/2013, 15/12/2013, 17/12/2013 that is six fields injected in like tour_date_1, tour_date_2 etc then do range query grouped or over those dates, although one problem will be knowing how many date fields to range over. Is there a max no of dates that a tour can occur on? I suspect not?
Regards
Ismail
Jason,
Not examine but lucene related see http://stackoverflow.com/questions/1655283/lucene-trouble-with-indexing-recurring-events ;
Regards
Ismail
You may just try using Examine for the non-date search fields, the filter the Examine results by date. Another thing I've done on a project is put the month as a new field in the GatheringNodeData event. In this case, you could narrow the results to the correct month (and the other non-date fields), then post-process the resutls (which is a much smaller set).
Just a couple of thoughts.
Thanks,
Jason
Hi Ismail & Jason,
Thanks for your replies. I'm currently in the process of following this tutorial to setup examine and try and get some search results appearing based upon multiple fields in an older project (still Umbraco 7 though):
http://24days.in/umbraco/2013/getting-started-with-examine/
I have setup my index as follows:
I have then setup the following index provider:
And search provider:
This appears to the successfully setup the temporary file under the path specified above however, when I try to rebuild this index from the Developer section is says that nothing has been indexed.
I'm also trying to run a simple query from a template page using the code provided in the tutorial above searching for 'BUE' which is a value I know features in one or more of my packages in the citycode property however I am getting an error in Visual Studio that:
Umbraco.Web.Models.RenderModel does not contain a definition for 'NodeById'
Any ideas why this isn't working?
Okay so I think I've solved the NodeById bit and have used the following instead:
However, my index is still returning 0 even when I rebuild it. Why is this happening? I have checked the document type alias and it is definitely package so this should be working.
Hi Jason,
I see you included package as allowed nodetype. Is that the exact alias of your doctype ?
Can you also post the code that is failing ?
dave
Hi Dave,
The document type alias is "package" as I always write my aliases lowercase. I have also checked this in the back office. There are no code errors now (as I fixed these in my template as I mentioned above) however like I say, no pages are being indexed under the new MyIndex in the Umbraco backoffice despite there being a large number of pages with the "package" document type alias.
Kind regards,
Jason Espin
Just a wild guess, but maybe you can hook in to the documentwriting or gathering node data events to see if these get fired when you publish a "package"
Dave
To be honest I'm starting to think that Examine just doesn't work. I've followed official Umbraco tutorials and yet nothing is being indexed. How would I go about hooking into those as the documentation is somewhat lacking?
Hey Jason,
Examine definitly works.We use it in al our sites.
Do the default indexes work ?
See below examples to hook in to the events.
Dave
Okay looking at my code I think I've found an issue in my indexer definition
should be
it appears I may have been using a member indexer rather than a content one.
I'm sure that is the cause.
Dave
That was the initial cause of the issues we were facing but in general Examine just doesn't seem to be very reliable.
We have setup a new document type with an alias of "tour" which has the following property and values:
tripType - "Private Tours"
However when we run the following query, nothing is returned:
What should be returned is the two tour pages that we have created with this type.
Jason,
can you open you index using luke and see if you have any docs, https://code.google.com/p/luke/downloads/list v350, it may be that you have no docs in your index.
Regards
Ismail
The Umbraco back office specifies that we have two documents in our Index
The Umbraco back office specifies that we have two documents in our Index
I have also tried opening the index files in Luke and confirm that the pages and the data we wish to search for are there.
Try doing a manual search using the search tools at the bottom of the Examine Manager tab. It may help to print our the compiled Lucene query to the page to get the exact search.
I have tried doing just a manual text search in the search tools and nothing is returned. It's odd because I have had a look in Luke and the data is indexed in there as expected but when I try and run a Lucene query in Luke or in Umbraco nothing is returned.
So what query are you executing ? Maybe there is a error in the query ?
Dave
We had the wrong analyzer included. Should have been this (apologies its been a long day):
Glad you sorted it out.
Dave
Good to hear!
is working on a reply...