logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Catmandu::Searchable - Optional role for searchable stores

Configuration

       default_limit
           The default value for "limit". By default this is 10.

       maximum_limit
           The maximum allowed value for "limit". By default this is 1000.

       maximum_offset
           The  maximum  allowed  offset.  When  set  no  hits will be returned after hit offset is greater than
           "maximum_offset", this to avoid deep paging problems.  Pagination values will  be  also  be  adjusted
           accordingly.

Cql Support

       Stores that are support the CQL query language <https://www.loc.gov/standards/sru/cql/> also  accept  the
       "cql_query" and "sru_sortkeys" arguments. See Catmandu::CQLSearchable for more information.

Methods

search(query=>$query,start=>$start,page=>$page,limit=>$num,sort=>$sort)
       Search  the  database  and returns a Catmandu::Hits on success. The Hits represents one result page of at
       most $num results. The $query and $sort should implement the query and  sort  syntax  of  the  underlying
       search engine.

       Optionally provide the index of the first result using the "start" option, or the starting page using the
       "page"  option.  The  number  of  records  in  a result page can be set using the "limit" option. Sorting
       options are being sent verbatim to the underlying search engine.

   searcher(query=>$query,start=>$start,limit=>$num,sort=>$sort,cql_query=>$cql)
       Search the database and return a Catmandu::Iterable on success. This iterator can be used  to  loop  over
       the  complete  result  set.  The  $query  and  $sort  should  implement  the query and sort syntax of the
       underlying search engine.

       Optionally provide the index of the first result using the "start" option. The number  of  records  in  a
       page  can  be  set  using  the  "limit" option. Sorting options are being sent verbatim to the underlying
       search engine.

   delete_by_query(query=>$query)
       Delete items from the database that match $query

Name

       Catmandu::Searchable - Optional role for searchable stores

See Also

       Catmandu::CQLSearchable, Catmandu::Hits, Catmandu::Paged

perl v5.40.0                                       2025-01-17                          Catmandu::Searchable(3pm)

Synopsis

           my $store = Catmandu::Store::Solr->new();

           # Return one page of search results (page size = 1000)
           my $hits  = $store->bag->search(
                  query => 'dna' ,
                  start => 0 ,
                  limit => 100 ,
                  sort  => 'title desc',
                       );

           # Return all the search results as iterator
           my $it    = $store->bag->searcher(query => 'dna');
           $it->each(sub { ...});

           $store->bag->delete_by_query(query => 'dna');

See Also