In the resulting array of search by sphinx indices, all found matches from different indices fall, but for some reason the array is formed only by a set of fields ( fields ) for the first index of the article:

array(10) { ["error"]=> string(0) "" ["warning"]=> string(0) "" ["status"]=> int(0) ["fields"]=> array(4) { [0]=> string(11) "articletime" [1]=> string(11) "articlename" [2]=> string(18) "articledescription" [3]=> string(11) "articletext" } ["attrs"]=> array(2) { ["type"]=> int(1) ["idn"]=> int(1) } ["matches"]=> array(4) { [483]=> array(2) { ["weight"]=> string(1) "3" ["attrs"]=> array(2) { ["type"]=> string(1) "3" ["idn"]=> string(2) "48" } } [542]=> array(2) { ["weight"]=> string(1) "3" ["attrs"]=> array(2) { ["type"]=> string(1) "1" ["idn"]=> string(2) "54" } } [713]=> array(2) { ["weight"]=> string(1) "1" ["attrs"]=> array(2) { ["type"]=> string(1) "3" ["idn"]=> string(2) "71" } } [723]=> array(2) { ["weight"]=> string(1) "1" ["attrs"]=> array(2) { ["type"]=> string(1) "3" ["idn"]=> string(2) "72" } } } ["total"]=> string(1) "4" ["total_found"]=> string(1) "4" ["time"]=> string(5) "0.002" ["words"]=> array(1) { ["nova"]=> array(2) { ["docs"]=> string(1) "4" ["hits"]=> string(1) "8" } } } 

T-processing the result of the matches, I can only display the values ​​of the first index field

An example of a config, 2 indexes are presented: #articles source articles: lsParentSource {

  sql_query_range = SELECT MIN(idArticle), MAX(idArticle) FROM article sql_range_step = 128 sql_query_pre = SET NAMES utf8 sql_query = \ SELECT idArticle * 10 + 2 as id, 1 as type, idarticle, idArticle as idn, articlecountry, articletime, articletouserid, articlecategory, ArticleName, ArticleDescription, ArticleText FROM article WHERE idArticle >= $start AND idArticle <= $end sql_attr_uint = idArticle sql_attr_uint = type sql_attr_uint = idn sql_attr_uint = ArticleToUserID sql_attr_uint = ArticleCategory sql_attr_uint = ArticleCountry sql_field_string = ArticleTime sql_field_string = ArticleName sql_field_string = ArticleDescription sql_field_string = ArticleText sql_query_info = SELECT ArticleName, ArticleText \ FROM article WHERE idArticle = ($id - 2) / 10 } #news source news : lsParentSource { sql_query_range = SELECT MIN(idNew), MAX(idNew) FROM new sql_range_step = 128 sql_query_pre = SET NAMES utf8 sql_query = \ SELECT idNew * 10 + 3 as id, 3 as type, NewName, idnew, idNew as idn, newtouserid, newcategory, newcountry, NewDescription, NewText, NewTime FROM new WHERE idNew >= $start AND idNew <= $end sql_attr_uint = idNew sql_attr_uint = type sql_attr_uint = idn sql_attr_uint = NewToUserID sql_attr_uint = NewCategory sql_attr_uint = NewCountry sql_attr_uint = NewTime sql_field_string = NewName sql_field_string = NewDescription sql_field_string = NewText sql_query_info = SELECT NewName, NewText \ FROM new WHERE idNew = ($id - 3) / 10 } 
  • one
    So the question is what? And give an example of a sphinx config - Johny
  • See, in an array of 4 matches found. But for some reason, there are only 2 attributes in this array: type, idn. In addition to the question I attach the config - Jony
  • What do you think? - Jony
  • Apparently, these are matching attributes that are in both indexes - Johny
  • one
    So the question is what? It’s not at all clear from your words what you want to achieve ;-) If you expect to see different fields from the first and second indexes in the answer, then nothing happens - in this respect the sphinx works like UNION in SQL, i.e. Only the fields that are in both indices at the same time will get into the result. If it doesn't fit, make two queries with an explicit indication of the index to use, and then combine the results as you need - Johny

1 answer 1

"If you expect to see in response," a ray appeared in the dark kingdom ... I do not know about that. But I do not understand, if the search is carried out on different indices (tables) - then it is not logical that it is impossible to get results from different indices. If I understand you, then if the sphinx found 3 records from the articles index (table) and 1 record from the news index, then the result will be ONLY 3 records from articles?