raja raja wrote on 5/10/18 3:18 PM:
> Hi Peter,
>
> After getting a little feel of using deziapp successfully (it rocks!), I am now experimenting with using dezi server and dezi-client, as follows:
>
> I run dezi server as:
> % dezi --dezi-config
deziconfig.pl
>
> #
deziconfig.pl
> {
> engine_config => {
> fields => [qw( product )], # result attributes in response
> },
> }
>
>
> Then I run default dezi-client successfully as:
>
> % dezi-client -q silk
> --
> uri: 51
> title: 51
> score: 287
> --
> uri: 53
> title: 53
> score: 233
> ========================================
> hits: 2
> search time: 0.00599
> build time: 0.00487
> query: silk
>
> Question: how to I get specific columns (e.g. 'product') when I run dezi-client?
You can't do arbitrary fields with the `dezi-client` command. You must write
your own (as below).
>
>
> Then I run a custom client program that uses dezi server:
>
>
customdeziclient.pl
> ------------------
> #!/perl/bin/perl
> use strict;
> use warnings;
> use Dezi::Client;
>
> # open a connection
> my $client = Dezi::Client->new(
> server => '
http://localhost:5000',
> );
>
> # search the index
> my $response = $client->search( q => 'silk' );
>
>
> # iterate over results
> for my $result (@{ $response->results }) {
> printf("--\n uri: %s\n title: %s\n score: %s\n",
> $result->uri, $result->title, $result->score);
> }
>
>
> #I tried this unsuccessfully
> for my $result (@{ $response->fields }) {
> print "\nproduct: $result->product\n";
> }
>
I think you want:
# iterate over results
for my $result (@{ $response->results }) {
printf(
"--\n uri: %s\n title: %s\n score: %s\nproduct: %s\n",
$result->uri, $result->title, $result->score,
$result->get_field('product'),
);
}
If you're still not seeing what you expect, make sure that the server is in fact
returning the 'product' field.
% curl '
http://localhost:5000/search?q=silk'
--
Peter Karman . he/him/his .
785.337.0405 .
https://karpet.github.io/