MySQL Full Text Search Returning 0 Results

PizzaTheHut

I have just set up a full text index on my MySQL database, but unfortunately it's not returning any results.

This seems to be a common issue, and the typical answers are use the MyISAM engine, and the 'IN BOOLEAN MODE' function. Well neither of these seem to work for me.

Here is my example code:

DROP TABLE IF EXISTS parentregionlist;
CREATE TABLE parentregionlist
(
    RegionID INT NOT NULL,
    RegionType VARCHAR(50),
    RelativeSignificance VARCHAR(3),
    SubClass VARCHAR(50),
    RegionName VARCHAR(255),
    RegionNameLong VARCHAR(510),
    ParentRegionID INT,
    ParentRegionType VARCHAR(50),
    ParentRegionName VARCHAR(255),
    ParentRegionNameLong VARCHAR(510),
    CountryCode VARCHAR(2),
  TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (RegionID),
    FULLTEXT (RegionNameLong)
) ENGINE = MyISAM;

INSERT INTO parentregionlist
VALUES (575, 
"City", 
"", 
"", 
"Birmingham", 
"Birmingham, England, United kingdom", 
6023342, 
"Multi-City (Vicinity)", 
"Birmingham (and Vicinity)", 
"Birmingham (and vicinity), England, United Kingdom", 
"", 
now());

SELECT * 
FROM parentregionlist
WHERE MATCH(regionnamelong) 
AGAINST ('Birm' IN BOOLEAN MODE);

Any ideas?

P.S. In the real table I have 200k+ rows. I know the search won't work with just one row, it's just an example.

user387049

With the current query you are looking for a full word match. So for instance to get the row you show inserted above, you would need to do:

SELECT * 
FROM parentregionlist
WHERE MATCH(regionnamelong) 
AGAINST ('Birmingham (and vicinity), England, United Kingdom' IN BOOLEAN MODE);

However if you want to search for all results that start with 'Birm' you will need to add the '*' modifier:

SELECT * 
FROM parentregionlist
WHERE MATCH(regionnamelong) 
AGAINST ('Birm*' IN BOOLEAN MODE);

Alternatively you could also use LIKE:

SELECT * 
FROM parentregionlist
WHERE regionnamelong LIKE 'Birm%';

The MySQL docs give good MATCH examples to work from: http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

MySQL full text search matching similar results

분류에서Dev

MySQL Full Text Search "AND" BOOLEAN MODE to ElasticSearch

분류에서Dev

full text search with multiple text input

분류에서Dev

Full text Search of browser history, through the browser

분류에서Dev

Full text search not giving desired result

분류에서Dev

NEST elasticsearch.NET search query not returning results (part 2)

분류에서Dev

Fuseki indexed (Lucene) text search returns no results

분류에서Dev

filter function ng-repeat returning true but 0 results are displayed

분류에서Dev

MySQL Random Select Query with limit returning different number of results (undesired)

분류에서Dev

GAE Full Text Search, querying multi-valued fields

분류에서Dev

ngResource search google news, but return results: Array[0]

분류에서Dev

Please help search results between MySQL and PHP using the LIKE operator

분류에서Dev

MySQL FULL TEXT 검색 최적화

분류에서Dev

Page not returning results

분류에서Dev

How to show full results, rather than matched text from regex searches in python

분류에서Dev

Alfresco Full Text Search for JSON 텍스트 파일에서 쿼리 구성

분류에서Dev

C# Full-text search string format : string remove all adjacent duplicates and append with 'AND' 'OR'

분류에서Dev

Why is Scrapy returning duplicate results?

분류에서Dev

Fuzzy logic search for full names

분류에서Dev

Difference in select query result on MyISAM Vs InnoDB MySQL engines(especially for FULL TEXT SEARCHES)

분류에서Dev

Timediff in mysql not returning result

분류에서Dev

mysql filtering results with subquery results

분류에서Dev

Simple Search with Rails - Search Results on Separate Page

분류에서Dev

double function only returning -0

분류에서Dev

Creating UTC time in momentjs is returning weird results

분류에서Dev

mysqli queries not returning results inside function

분류에서Dev

scraper only returning results for first 2 inputs

분류에서Dev

ElasticSearch Ruby returning results without ElasticSearch running

분류에서Dev

nslookup returning fake results for one particular domain

Related 관련 기사

  1. 1

    MySQL full text search matching similar results

  2. 2

    MySQL Full Text Search "AND" BOOLEAN MODE to ElasticSearch

  3. 3

    full text search with multiple text input

  4. 4

    Full text Search of browser history, through the browser

  5. 5

    Full text search not giving desired result

  6. 6

    NEST elasticsearch.NET search query not returning results (part 2)

  7. 7

    Fuseki indexed (Lucene) text search returns no results

  8. 8

    filter function ng-repeat returning true but 0 results are displayed

  9. 9

    MySQL Random Select Query with limit returning different number of results (undesired)

  10. 10

    GAE Full Text Search, querying multi-valued fields

  11. 11

    ngResource search google news, but return results: Array[0]

  12. 12

    Please help search results between MySQL and PHP using the LIKE operator

  13. 13

    MySQL FULL TEXT 검색 최적화

  14. 14

    Page not returning results

  15. 15

    How to show full results, rather than matched text from regex searches in python

  16. 16

    Alfresco Full Text Search for JSON 텍스트 파일에서 쿼리 구성

  17. 17

    C# Full-text search string format : string remove all adjacent duplicates and append with 'AND' 'OR'

  18. 18

    Why is Scrapy returning duplicate results?

  19. 19

    Fuzzy logic search for full names

  20. 20

    Difference in select query result on MyISAM Vs InnoDB MySQL engines(especially for FULL TEXT SEARCHES)

  21. 21

    Timediff in mysql not returning result

  22. 22

    mysql filtering results with subquery results

  23. 23

    Simple Search with Rails - Search Results on Separate Page

  24. 24

    double function only returning -0

  25. 25

    Creating UTC time in momentjs is returning weird results

  26. 26

    mysqli queries not returning results inside function

  27. 27

    scraper only returning results for first 2 inputs

  28. 28

    ElasticSearch Ruby returning results without ElasticSearch running

  29. 29

    nslookup returning fake results for one particular domain

뜨겁다태그

보관