The App
I've got a search function that searches a Sharepoint List (LinksAndResources) to return results that match the text input. It currently returns the results based on a defined numerical priority ("Highlight" column).
The Problem
However, what I want is for it to sort the results based on whether each of the words in the query is found in the "Title" column, putting these results at the top. However, I still want the results that aren't just found in the title (for example, only found in the description).
I was hoping to figure out a code that essentially sorts:
1. First by "Group 1: [input text] is in [Title]" (then sorted by the numeric value in the "highlight" column),
2. Then provides the rest of the results for "Group 2: [input text] is NOT in [Title]" (then displayed as sorted by the numeric value in the highlight column).
I don't want it obvious to users that it's grouped.
I was thinking it could also just search for results in the "Title" column only, then do a separate search for results in the "Description" column, and then concatenate the results to be ordered as above, but I don't know how to do that, nor how to do it without duplicating the results from the top section.
EXAMPLE
If I were to search "duck templates", I would want "templates of ducks" to be my first search result, with any other results that mention "duck" and "templates" to be included underneath.
For example, if the sharepoint main list has:
(Title/Description/Highlight)
Duck templates / A list of duck templates to explain mallard mating habits / 4
Goose templates / A list of goose templates to explain goose mating habits. Also includes some ducks. / 3
Penguin descriptions / A list of penguin descriptions. Also discusses penguin, duck, and puffin locations. / 5
Parrot descriptions / A list of parrot descriptions and templates. Compares them to the standard duck. /1
Puffin locations / A list of puffin locations. Contains templates for the ducks. /2
PDFs of duck templates / A pdf list of all the duck templates / 6
As it only checks for the words and then sorts by highlight, my current results would show up like this:
CURRENT SEARCH RESULT ORDER
Parrot descriptions / A list of parrot descriptions and templates. Compares them to the standard duck. /1
Puffin locations / A list of puffin locations and templates. Contains a database for the ducks. /2
Goose templates / A list of goose templates to explain goose mating habits. Also includes some duck pictures. / 3
Templates of ducks / A list of duck and other waterfowl templates to explain mallard mating habits / 4
PDFs of duck templates / A pdf list of all the duck templates / 6
[Penguin descriptions doesn't show as it contains "duck" but not "templates")
When I would prefer them to show up like:
PREFERRED SEARCH RESULT ORDER
Templates of ducks / A list of duck and other waterfowl templates to explain mallard mating habits / 4
PDFs of duck templates / A pdf list of all the duck templates / 6
Parrot descriptions / A list of parrot descriptions and templates. Compares them to the standard duck. /1
Puffin locations / A list of puffin locations and templates. Contains a database for the ducks. /2
Goose templates / A list of goose templates to explain goose mating habits. Also includes some duck pictures. /
CURRENT CODE
Current code to return search results:
Search(Search(Search(Search(Search(Sort(LinksAndResources,Highlight),Last(FirstN(TrimEnds(Split(inpSearch.Text," ")),1)).Result,"Topic","Title","Description"),Last(FirstN(TrimEnds(Split(inpSearch.Text," ")),2)).Result,"Topic","Title","Description"),Last(FirstN(TrimEnds(Split(inpSearch.Text," ")),3)).Result,"Topic","Title","Description"),Last(FirstN(TrimEnds(Split(inpSearch.Text," ")),4)).Result,"Topic","Title","Description"),Last(FirstN(TrimEnds(Split(inpSearch.Text," ")),5)).Result,"Topic","Title","Description")

Report
All responses (
Answers (