I am using umbraco version 7.5. I added a simple search page which returns me result well if I pass a single parameter in query string. Some thing like that
Ajax shouldn't really pose any additional constraint. Just return a JsonResult e.g.
var myResults = new List<MyTypedResultObject>();
//.... populate results
return Json(myResults);
However, instead of using Json you could just return the HTML which is required to replace your results. This works just the same as a Partial. Return a PartialResult and have your view render the results.
If your surface controller has arguments for all your filters then that should be straight forward.
I am doing code something like that but no luck with date range
var q = "Policy Publication";
var q_split = q.Split(' ');
var Searcher = Examine.ExamineManager.Instance.SearchProviderCollection["MySearcher"];
var searchCriteria = Searcher.CreateSearchCriteria(BooleanOperation.Or);
var fieldsToSearch = new[]
{
"type", "format", "nodeName", "createdDate"
};
IBooleanOperation filter = searchCriteria.GroupedOr(fieldsToSearch, q_split.First());
foreach (var term in q_split.Skip(1))
{
filter = filter.Or().GroupedOr(fieldsToSearch, term);
}
//Put if condition for date range
filter = filter.And().Range("createdDate", new DateTime(2017, 03, 01), new DateTime(2017, 03, 05));
var searchResults = Searcher.Search(filter.Compile());
You probably need to use the GatheringNodeData examine event to populate a field with the format yyyyMMddHHmmss. Plus I'm not sure range works. You might need to do a greater than and a less than.
var query = String.Format("{0}:[{1}* TO {2}*]", "createdDate", new DateTime(2017, 02, 01).ToString("yyyyMMdd"), new DateTime(2017, 03, 05).ToString("yyyyMMdd"));
filter = filter.And().GroupedOr(fieldsToSearch, query);
Examine search with surface controller
Hi
I am using umbraco version 7.5. I added a simple search page which returns me result well if I pass a single parameter in query string. Some thing like that
http://localhost:83/search/?search=Publication
It is works fine but my case is little different. I have a list of check boxes and i want to refine results on basis of check box selection.
Here are few points on which can someone help me out
Manish
Hi Manish,
Ajax shouldn't really pose any additional constraint. Just return a JsonResult e.g.
However, instead of using Json you could just return the HTML which is required to replace your results. This works just the same as a Partial. Return a PartialResult and have your view render the results.
If your surface controller has arguments for all your filters then that should be straight forward.
thanks for giving me a start.
I am doing code something like that but no luck with date range
You probably need to use the GatheringNodeData examine event to populate a field with the format yyyyMMddHHmmss. Plus I'm not sure range works. You might need to do a greater than and a less than.
You can do date range searches uses Lucene (Examine) but you might need to create a raw query. This is how I format it:
dateField is the name of the field in your index that holds the date fromDate and toDate are DateTime values for your date range.
Hi Dan Diplo
I just added like this but not able to filter
Manish
Just done with this
Thanks all for your valueble support
Manish
How can i apply pagination when i am getting results through Ajax. Any code snippet please.
Manish
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.