dezi-client

5 views
Skip to first unread message

raja raja

unread,
May 10, 2018, 4:18:10 PM5/10/18
to dezi-...@googlegroups.com
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?


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";
}

Same question: How to get this script to output specific column fields (e.g. 'product')?

Thank you!

Peter Karman

unread,
May 10, 2018, 4:27:17 PM5/10/18
to dezi-...@googlegroups.com
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/

raja raja

unread,
May 14, 2018, 2:09:56 PM5/14/18
to dezi-...@googlegroups.com
Yes, that did the trick. $result->get_field('product') gave me an array ref, and I used this to get the content therein:

print join(", ", @{$result->get_field('product')}), "\n";

Thanks Peter!


> Sent: Thursday, May 10, 2018 at 1:27 PM
> From: "Peter Karman" <pe...@peknet.com>
> To: dezi-...@googlegroups.com
> Subject: Re: [dezi-search] dezi-client
> --
> Dezi search platform . http://dezi.org/
> ---
> You received this message because you are subscribed to the Google Groups "dezi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dezi-search...@googlegroups.com.
> To post to this group, send email to dezi-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/dezi-search.
> For more options, visit https://groups.google.com/d/optout.
>
Reply all
Reply to author
Forward
0 new messages