Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

we have a customer reacting about the "all these words" feature in advanced search. If you search for a word in "simple search" you get for instance 34 hits. If you search for the same word in advanced, you get the ALL({word}) search query. This reduces the number of hits to exactly 1, as the ALL() means the exact word as far as I have managed to see.

Is there any way to not have the "ALL"-limitation in advanced search? So that it searches in the same way, but you can then filter via your own limitations?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

I solved it like this: I added a script-file, put it on the "Advanced search" page using content editor web part, and added a function called ComposeTextSectionQuery with a signature of ComposeTextSectionQuery(elements) in this file. This effectively replaced the original function with the same name, and then removed the "ALL" keyword like this:

    function ComposeTextSectionQuery(elements) {
    // Replace of original function!
    var allQuery = elements.AndQueryTextBox.value != '' ? elements.AndQueryTextBox.value : '';
    var phraseQuery = elements.PhraseQueryTextBox.value != '' ? enquote(elements.PhraseQueryTextBox.value): '';
    var anyQuery = elements.OrQueryTextBox.value != '' ? 'ANY(' + elements.OrQueryTextBox.value + ')': '';
    var noneQuery = elements.NotQueryTextBox.value ? 'NONE(' + elements.NotQueryTextBox.value + ')' : '';
    if (phraseQuery == '' && anyQuery == '' && noneQuery == '' && allQuery == '') 
    {
        allQuery = 'ALL()';
    }

    return ConcatenateQueryParts(allQuery, phraseQuery, anyQuery, noneQuery);
}
share|improve this answer
add comment

Since the query from the advanced search is passed through URL, using JavaScript code you can grab the URL and change the query.

for example instead of:

http://myServer/search/Pages/results.aspx?k=ALL(yourword) 

with some JavaScript code:

//var url=window.location;
var url="http://myServer/search/Pages/results.aspx?k=ALL(yourword)";
var str1 = url.replace("ALL(","");
var str2 = str1.replace(")","")
alert(str2);

change it to:

http://myServer/search/Pages/results.aspx?k=yourword 
share|improve this answer
    
Where would I put this JavaScript-code to get it to work? –  sarcophilus Apr 23 '13 at 9:24
    
you can hook to the click event using JQuery, so when the user clicks on the search button in advanced search, you can use the code above to change the url. –  Alex Choroshin Apr 23 '13 at 10:45
    
This would probably work, but I found an easier solution. I added a script-file, put it on the "Advanced search" page using content editor web part, and added a function called ComposeTextSectionQuery in this file. This effectively replaced the original function with the same name, and then removed the "ALL" keyword –  sarcophilus Jun 25 '13 at 13:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.