Multiple OR searches, sorted by number of results found

Multiple OR searches, sorted by number of results found

GstgGstg Posts: 66Questions: 4Answers: 0

Is there a way to search using OR, similar to Google results. Meaning if I searched for "Hikes that have waterfalls", Google will do 3 things:

1 - Remove the common words "that" & "have" - which i have already been able to do
2 - Will search using OR for results that either have the word "Hike" or "waterfall"
3 - Sort the order of the results by first results that have ALL results, then by results that have less results

The closest thing I have found in my searching is the following example:

http://live.datatables.net/ginayero/2/edit

But this does not seem to use the regular Search box, which is what I'm trying to do.

Thanks in advance for the amazing assistance this forum has provided already.

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    The search isn't smart enough to do 1, and the ordering is defined by the column's ordering, so 3 is a no go. That said, with 3, you could use a hidden colunms, like this example from this thread, to keep a record at the top. You could add the hidden column in drawCallback depending on whether a search is present, and the display contains all matching records.

    For 2, you can use a regex with search() to give OR logic - like here: http://live.datatables.net/batoxoko/1/edit

    Colin

  • GstgGstg Posts: 66Questions: 4Answers: 0

    That is an awesome example. Since the search could be done using the (X|Y) type search, is there an easy way to replace the search with a custom search button that I could run logic on before submitting it to the search parameter? I sort of did this when I was passing search criteria from one page to another. Since the variable was POSTed I used it and took out common words before submitting it to the post.

    I'm almost thinking I could write a custom button, and turn off the search entirely, and then just redraw the page using the new modified search parameters? Is there an easy way to turn off the search?

    Thoughts?

    Thanks for the great support on this forum btw 8-)

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    is there an easy way to replace the search with a custom search

    Yep, this example here shows how you can repurpose the standard search control - it's removing paging when a search is entered.

    If you want a search button or to remove the standard search input element, you can use dom.

    And thanks for the thoughts - there's some great community support on this forum!

    Colin

This discussion has been closed.