Php WP_查询按大多数匹配值排序(不包括ACS部分和DESC其他)
我有下面的示例查询,其中结果首先基于位置返回,通常可以使用Php WP_查询按大多数匹配值排序(不包括ACS部分和DESC其他),php,wordpress,Php,Wordpress,我有下面的示例查询,其中结果首先基于位置返回,通常可以使用meta_查询进行更多过滤 问题是,我不完全确定如何根据匹配All/Most的个体对结果进行排序,然后是匹配Less的个体,最后是匹配Less 为了澄清meta_查询,1个值的权重并不大于另一个值 $args = array( 'update_post_term_cache' => false, 'post_type' => 'vandelay_industrie
meta_查询
进行更多过滤
问题是,我不完全确定如何根据匹配All/Most
的个体对结果进行排序,然后是匹配Less
的个体,最后是匹配Less
为了澄清meta_查询
,1个值的权重并不大于另一个值
$args = array(
'update_post_term_cache' => false,
'post_type' => 'vandelay_industries',
'posts_per_page' => $request['per_page'],
'paged' => $request['page'],
'geo_query' => array(
'lat_field' => 'flat_lat', // this is the name of the meta field storing latitude
'lng_field' => 'flat_lng', // this is the name of the meta field storing longitude
'latitude' => $lat1, // this is the latitude of the point we are getting distance from
'longitude' => $lng1, // this is the longitude of the point we are getting distance from
'distance' => $proximity, // this is the maximum distance to search
'units' => 'miles' // this supports options: miles, mi, kilometers, km
),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'hair_types',
'value' => $value1,
'compare' => 'LIKE'
),
array(
'key' => 'education_type',
'value' => $value2,
'compare' => 'IN'
),
array(
'key' => 'something_else',
'value' => $value3,
'compare' => 'LIKE'
),
array(
'key' => 'george_is_getting_upset',
'value' => $value4,
'compare' => 'IN'
),
)
);
我不是一个超级sql专家,也许我错了,但OR子句将在满足任何条件时返回结果。所以,如果头发类型像$value,返回结果,其他条件将不会被检查。所以我不认为可以按大多数匹配值排序,因为一旦得到1个匹配项,就会返回结果。我将对您的问题进行投票,然后再进行讨论,因为它非常有趣,希望一些SQL专家能够看到它并给出可靠的答案answer@AngelDeykov这是一个极好的观点。我将很快进行细化,以包括AND或2的组合,以进行澄清。