substring in search queries

This commit is contained in:
Michele Artini 2021-07-01 11:13:09 +02:00
parent 878171b204
commit 80d0aba5c3
1 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@ public interface OrganizationSimpleViewRepository extends ReadOnlyRepository<Org
+ " LEFT OUTER JOIN acronyms a ON org.id = a.id\n"
+ " LEFT OUTER JOIN urls u ON org.id = u.id\n"
+ " LEFT OUTER JOIN oa_duplicates d1 ON org.id = d1.local_id\n"
+ "WHERE idx.txt @@ plainto_tsquery(:text) AND org.status in :statuses\n"
+ "WHERE org.status in :statuses AND (org.name ilike '%'||:text||'%' OR idx.txt @@ plainto_tsquery(:text))\n"
+ "GROUP BY org.id, org.name, org.type, org.city, org.country, org.status\n"
+ "ORDER BY org.name", nativeQuery = true)
Page<OrganizationSimpleView> search(@Param("text") String text, @Param("statuses") List<String> statuses, Pageable pageable);
@ -55,7 +55,7 @@ public interface OrganizationSimpleViewRepository extends ReadOnlyRepository<Org
+ " LEFT OUTER JOIN urls u ON (org.id = u.id)\n"
+ " LEFT OUTER JOIN oa_duplicates d1 ON (org.id = d1.local_id)\n"
+ " LEFT OUTER JOIN user_countries uc ON (uc.country = org.country) \n"
+ "WHERE idx.txt @@ plainto_tsquery(:text) AND uc.email = :email AND org.status IN :statuses \n"
+ "WHERE uc.email = :email AND org.status IN :statuses AND (org.name ilike '%'||:text||'%' OR idx.txt @@ plainto_tsquery(:text))\n"
+ "GROUP BY org.id, org.name, org.type, org.city, org.country, org.status\n"
+ "ORDER BY org.name", nativeQuery = true)
Page<OrganizationSimpleView> searchForUser(@Param("text") String text,
@ -99,7 +99,7 @@ public interface OrganizationSimpleViewRepository extends ReadOnlyRepository<Org
+ " LEFT OUTER JOIN acronyms a ON (org.id = a.id)\n"
+ " LEFT OUTER JOIN urls u ON (org.id = u.id)\n"
+ " LEFT OUTER JOIN oa_duplicates d2 ON (org.id = d2.oa_original_id)\n"
+ "WHERE org.status = 'raw' AND idx.txt @@ plainto_tsquery(:text)\n"
+ "WHERE org.status = 'raw' AND (org.name ilike '%'||:text||'%' OR idx.txt @@ plainto_tsquery(:text))\n"
+ "GROUP BY org.id, org.name, org.type, org.city, org.country, org.status\n"
+ "HAVING not('is_similar' = ANY(array_agg(d2.reltype)))\n"
+ "ORDER BY org.name", nativeQuery = true)
@ -124,7 +124,7 @@ public interface OrganizationSimpleViewRepository extends ReadOnlyRepository<Org
+ " LEFT OUTER JOIN urls u ON (org.id = u.id)\n"
+ " LEFT OUTER JOIN oa_duplicates d2 ON (org.id = d2.oa_original_id)\n"
+ " LEFT OUTER JOIN user_countries uc ON (uc.country = org.country)\n"
+ "WHERE org.status = 'raw' AND uc.email = :email AND idx.txt @@ plainto_tsquery(:text)\n"
+ "WHERE org.status = 'raw' AND uc.email = :email AND (org.name ilike '%'||:text||'%' OR idx.txt @@ plainto_tsquery(:text))\n"
+ "GROUP BY org.id, org.name, org.type, org.city, org.country, org.status\n"
+ "HAVING not('is_similar' = ANY(array_agg(d2.reltype)))\n"
+ "ORDER BY org.name", nativeQuery = true)