FullText indexes in multiple variable columns











up vote
1
down vote

favorite












I am currently looking into using FULLTEXT indexes in MySQL for search functionality within a web site.



Basically, the user can go to an advanced search page, and select 1 or more columns to search against, e.g. they can search Title, Description and Comments or either only 1 column or a mixture of the three and when they perform the search these selected columns are searched for against the keywords.



I had created 1 index for the title, 1 index for the description and 1 index for the comments and then tried to run the following query:



SELECT * FROM support_calls WHERE MATCH(Title, Description) AGAINST('+these, +are, +some, +keywords')


I got an error from MySQL saying that the MATCH didn't match any fulltext indexes and I found that I need to create an index which included Title and Description together instead of having them in separate indexes.



This is going to add some complexity if this is the case as I am going to have to create an index for every single variation of what columns the user selects. Am I going about this the right away or is there a better solution?










share|improve this question
























  • AFAIK that's a MySQL restriction you can't override. Depending on your needs, you may be able to MATCH(Title) AGAINST('+these, +are, +some, +keywords') OR MATCH(Description) AGAINST('+these, +are, +some, +keywords') and use ranks to sort or further filtering.
    – Álvaro González
    Jan 13 '16 at 12:08










  • This seems to work from the test I've done, I'm a bit worried it may get quite slow but so far so good. Could you make this an answer and I'll accept it
    – Boardy
    Jan 13 '16 at 14:05










  • I'm far from being an expert in full text and I don't want to post a potentially misleading or plain wrong answer. For instance, I've just leant that index requirements are different depending on storage engine and boolean/natural mode ref.
    – Álvaro González
    Jan 13 '16 at 17:10















up vote
1
down vote

favorite












I am currently looking into using FULLTEXT indexes in MySQL for search functionality within a web site.



Basically, the user can go to an advanced search page, and select 1 or more columns to search against, e.g. they can search Title, Description and Comments or either only 1 column or a mixture of the three and when they perform the search these selected columns are searched for against the keywords.



I had created 1 index for the title, 1 index for the description and 1 index for the comments and then tried to run the following query:



SELECT * FROM support_calls WHERE MATCH(Title, Description) AGAINST('+these, +are, +some, +keywords')


I got an error from MySQL saying that the MATCH didn't match any fulltext indexes and I found that I need to create an index which included Title and Description together instead of having them in separate indexes.



This is going to add some complexity if this is the case as I am going to have to create an index for every single variation of what columns the user selects. Am I going about this the right away or is there a better solution?










share|improve this question
























  • AFAIK that's a MySQL restriction you can't override. Depending on your needs, you may be able to MATCH(Title) AGAINST('+these, +are, +some, +keywords') OR MATCH(Description) AGAINST('+these, +are, +some, +keywords') and use ranks to sort or further filtering.
    – Álvaro González
    Jan 13 '16 at 12:08










  • This seems to work from the test I've done, I'm a bit worried it may get quite slow but so far so good. Could you make this an answer and I'll accept it
    – Boardy
    Jan 13 '16 at 14:05










  • I'm far from being an expert in full text and I don't want to post a potentially misleading or plain wrong answer. For instance, I've just leant that index requirements are different depending on storage engine and boolean/natural mode ref.
    – Álvaro González
    Jan 13 '16 at 17:10













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am currently looking into using FULLTEXT indexes in MySQL for search functionality within a web site.



Basically, the user can go to an advanced search page, and select 1 or more columns to search against, e.g. they can search Title, Description and Comments or either only 1 column or a mixture of the three and when they perform the search these selected columns are searched for against the keywords.



I had created 1 index for the title, 1 index for the description and 1 index for the comments and then tried to run the following query:



SELECT * FROM support_calls WHERE MATCH(Title, Description) AGAINST('+these, +are, +some, +keywords')


I got an error from MySQL saying that the MATCH didn't match any fulltext indexes and I found that I need to create an index which included Title and Description together instead of having them in separate indexes.



This is going to add some complexity if this is the case as I am going to have to create an index for every single variation of what columns the user selects. Am I going about this the right away or is there a better solution?










share|improve this question















I am currently looking into using FULLTEXT indexes in MySQL for search functionality within a web site.



Basically, the user can go to an advanced search page, and select 1 or more columns to search against, e.g. they can search Title, Description and Comments or either only 1 column or a mixture of the three and when they perform the search these selected columns are searched for against the keywords.



I had created 1 index for the title, 1 index for the description and 1 index for the comments and then tried to run the following query:



SELECT * FROM support_calls WHERE MATCH(Title, Description) AGAINST('+these, +are, +some, +keywords')


I got an error from MySQL saying that the MATCH didn't match any fulltext indexes and I found that I need to create an index which included Title and Description together instead of having them in separate indexes.



This is going to add some complexity if this is the case as I am going to have to create an index for every single variation of what columns the user selects. Am I going about this the right away or is there a better solution?







mysql full-text-indexing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 17:56









halfer

14.2k757104




14.2k757104










asked Jan 13 '16 at 12:03









Boardy

14.1k79205357




14.1k79205357












  • AFAIK that's a MySQL restriction you can't override. Depending on your needs, you may be able to MATCH(Title) AGAINST('+these, +are, +some, +keywords') OR MATCH(Description) AGAINST('+these, +are, +some, +keywords') and use ranks to sort or further filtering.
    – Álvaro González
    Jan 13 '16 at 12:08










  • This seems to work from the test I've done, I'm a bit worried it may get quite slow but so far so good. Could you make this an answer and I'll accept it
    – Boardy
    Jan 13 '16 at 14:05










  • I'm far from being an expert in full text and I don't want to post a potentially misleading or plain wrong answer. For instance, I've just leant that index requirements are different depending on storage engine and boolean/natural mode ref.
    – Álvaro González
    Jan 13 '16 at 17:10


















  • AFAIK that's a MySQL restriction you can't override. Depending on your needs, you may be able to MATCH(Title) AGAINST('+these, +are, +some, +keywords') OR MATCH(Description) AGAINST('+these, +are, +some, +keywords') and use ranks to sort or further filtering.
    – Álvaro González
    Jan 13 '16 at 12:08










  • This seems to work from the test I've done, I'm a bit worried it may get quite slow but so far so good. Could you make this an answer and I'll accept it
    – Boardy
    Jan 13 '16 at 14:05










  • I'm far from being an expert in full text and I don't want to post a potentially misleading or plain wrong answer. For instance, I've just leant that index requirements are different depending on storage engine and boolean/natural mode ref.
    – Álvaro González
    Jan 13 '16 at 17:10
















AFAIK that's a MySQL restriction you can't override. Depending on your needs, you may be able to MATCH(Title) AGAINST('+these, +are, +some, +keywords') OR MATCH(Description) AGAINST('+these, +are, +some, +keywords') and use ranks to sort or further filtering.
– Álvaro González
Jan 13 '16 at 12:08




AFAIK that's a MySQL restriction you can't override. Depending on your needs, you may be able to MATCH(Title) AGAINST('+these, +are, +some, +keywords') OR MATCH(Description) AGAINST('+these, +are, +some, +keywords') and use ranks to sort or further filtering.
– Álvaro González
Jan 13 '16 at 12:08












This seems to work from the test I've done, I'm a bit worried it may get quite slow but so far so good. Could you make this an answer and I'll accept it
– Boardy
Jan 13 '16 at 14:05




This seems to work from the test I've done, I'm a bit worried it may get quite slow but so far so good. Could you make this an answer and I'll accept it
– Boardy
Jan 13 '16 at 14:05












I'm far from being an expert in full text and I don't want to post a potentially misleading or plain wrong answer. For instance, I've just leant that index requirements are different depending on storage engine and boolean/natural mode ref.
– Álvaro González
Jan 13 '16 at 17:10




I'm far from being an expert in full text and I don't want to post a potentially misleading or plain wrong answer. For instance, I've just leant that index requirements are different depending on storage engine and boolean/natural mode ref.
– Álvaro González
Jan 13 '16 at 17:10












1 Answer
1






active

oldest

votes

















up vote
0
down vote













first execute below query and then run your MATCH() query.



ALTER TABLE support_calls ADD FULLTEXT (
Title, Description
)





share|improve this answer





















  • The OP already acknowledges that. The question is about an alternative to creating a new index for every possible column combination.
    – Álvaro González
    Jan 13 '16 at 12:27










  • you can also use like %word% or any other wild card characters instead of MATCH
    – Rakesh Sojitra
    Jan 13 '16 at 12:34













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34766239%2ffulltext-indexes-in-multiple-variable-columns%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













first execute below query and then run your MATCH() query.



ALTER TABLE support_calls ADD FULLTEXT (
Title, Description
)





share|improve this answer





















  • The OP already acknowledges that. The question is about an alternative to creating a new index for every possible column combination.
    – Álvaro González
    Jan 13 '16 at 12:27










  • you can also use like %word% or any other wild card characters instead of MATCH
    – Rakesh Sojitra
    Jan 13 '16 at 12:34

















up vote
0
down vote













first execute below query and then run your MATCH() query.



ALTER TABLE support_calls ADD FULLTEXT (
Title, Description
)





share|improve this answer





















  • The OP already acknowledges that. The question is about an alternative to creating a new index for every possible column combination.
    – Álvaro González
    Jan 13 '16 at 12:27










  • you can also use like %word% or any other wild card characters instead of MATCH
    – Rakesh Sojitra
    Jan 13 '16 at 12:34















up vote
0
down vote










up vote
0
down vote









first execute below query and then run your MATCH() query.



ALTER TABLE support_calls ADD FULLTEXT (
Title, Description
)





share|improve this answer












first execute below query and then run your MATCH() query.



ALTER TABLE support_calls ADD FULLTEXT (
Title, Description
)






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 13 '16 at 12:25









Rakesh Sojitra

2,1621721




2,1621721












  • The OP already acknowledges that. The question is about an alternative to creating a new index for every possible column combination.
    – Álvaro González
    Jan 13 '16 at 12:27










  • you can also use like %word% or any other wild card characters instead of MATCH
    – Rakesh Sojitra
    Jan 13 '16 at 12:34




















  • The OP already acknowledges that. The question is about an alternative to creating a new index for every possible column combination.
    – Álvaro González
    Jan 13 '16 at 12:27










  • you can also use like %word% or any other wild card characters instead of MATCH
    – Rakesh Sojitra
    Jan 13 '16 at 12:34


















The OP already acknowledges that. The question is about an alternative to creating a new index for every possible column combination.
– Álvaro González
Jan 13 '16 at 12:27




The OP already acknowledges that. The question is about an alternative to creating a new index for every possible column combination.
– Álvaro González
Jan 13 '16 at 12:27












you can also use like %word% or any other wild card characters instead of MATCH
– Rakesh Sojitra
Jan 13 '16 at 12:34






you can also use like %word% or any other wild card characters instead of MATCH
– Rakesh Sojitra
Jan 13 '16 at 12:34




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34766239%2ffulltext-indexes-in-multiple-variable-columns%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python