Dezi config

5 views
Skip to first unread message

raja raja

unread,
May 15, 2018, 3:33:35 PM5/15/18
to dezi-...@googlegroups.com
Hi Peter,

I am now trying to get a handle on using full dezi config file shown on https://metacpan.org/pod/Dezi::Config .

Here is what I did:

1. %dezi --dezi-config deziconfig.pl

I get the following error:

Error parsing deziconfig.pl: Undefined subroutine &Dezi::Config called at deziconfig.pl line 8.
at /home/user1/perl5/perlbrew/perls/perl-5.24.0/bin/dezi line 58.

2. Earlier in my simpler setting where dezi client ran ok, when I tried running ui in my browser, e.g., http://localhost:5000/ui , I get error: 'Resource not found'. May be this path '/ui' is not set as default and I need to spell it out in the config file!

3. One other question, what should I do in my dezi client script for executing a complex query that matches terms in different columns (something like a where clause in sql), e.g.: $query='field1:term1 AND field2:term2',

Or to do complete field/column match: equivalent to using regex like, $field1=~/^term1$/

Thank you much!


#deziconfig.pl
---------------
#!/usr/bin/perl
use strict;
use warnings;

use Dezi::Config;
use CHI;

my $dezi_config = Dezi::Config({

search_path => '/search',
index_path => '/index',
commit_path => '/commit',
rollback_path => '/rollback',
ui_path => '/ui',
ui_class => 'Dezi::UI',
# or
# ui => Dezi::UI->new()

admin_path => '/admin',
admin_class => 'Dezi::Admin',
# or
# admin => Dezi::Admin->new(),

base_uri => '',
server_class => 'Dezi::Server',

# authentication for non-idempotent requests.
# if both username && password are defined,
# then /index, /commit and /rollback require
# basic authentication credentials.
username => 'someone',
password => 'somesecret',

# # optional
# # see Dezi::Stats
# stats_logger => Dezi::Stats->new(
# type => 'DBI',
# dsn => 'DBI::mysql:database=mydb;host=localhost;port=3306',
# username => 'myuser',
# password => 'mysecret',
# ),

# see Search::OpenSearch::Engine
engine_config => {

default_response_format => 'JSON',

# could be any Search::OpenSearch::Engine::* class
type => 'Lucy',

# name of the index(es)
index => [qw( dezi.index )],

# which facets to calculate, and how many results to consider
facets => {
names => [qw( product type )],
sample_size => 10_000,
},

# result attributes in response
fields => [qw( product type )],

# options passed to indexer defined by Engine type (above)
# defaults to Dezi::Lucy::Indexer->new
indexer_config => {

# see Dezi::Indexer::Config
# and http://swish-e.org/docs/swish-config.html
config => {

# searchable fields
MetaNames => 'product type',

# attributes to store
PropertyNames => 'product type',

# auto-vivify new fields based on POSTed docs.
# use this if you want ElasticSearch-like effect.
UndefinedMetaTags => 'auto',

# treat unknown mime types as text/plain
DefaultContents => 'TXT',

# use English snowball stemmer
FuzzyIndexingMode => 'Stemming_en1',

},

# store token positions to optimize snippet creation
highlightable_fields => 1,
},

# options passed to searcher defined by Engine type (above)
# defaults to Dezi::Lucy::Searcher->new
searcher_config => {
max_hits => 1000,
find_relevant_fields => 1,
qp_config => {
dialect => 'Lucy',
null_term => 'NULL',
# see Search::Query::Parser and Search::Query::Dialect::Lucy
# for full list of options
},
},

# # see LucyX::Suggester
# suggester_config => {
# limit => 10,
# fields => [qw( color size )],
#
# # passed to Search::Tools::Spellcheck->new
# # along with parser_config
# spellcheck_config => {
# lang => 'en_US',
# },
# },

# cache facets for speed-up.
# this is the Search::OpenSearch default setting
cache => CHI->new(
driver => 'File',
dir_create_mode => 0770,
file_create_mode => 0660,
root_dir => ".",
),

# how long should the facet cache live
# each cache entry is per-unique-query
cache_ttl => 3600,

# # explicitly turn off highlighting for some fields
# do_not_hilite => { color => 1 },

# see Search::Tools::Snipper
snipper_config => { as_sentences => 1, strip_markup => 1, },

# see Search::Tools::HiLiter
hiliter_config => { class => 'h', tag => 'b' },

# see Search::Tools::QueryParser
parser_config => {},

# see Search::OpenSearch::Engine::Lucy
auto_commit => 1, # set to 0 to enable transactions with /commit and /rollback

}

});

Peter Karman

unread,
May 15, 2018, 5:27:19 PM5/15/18
to dezi-...@googlegroups.com
raja raja wrote on 5/15/18 2:33 PM:

> Here is what I did:
>
> 1. %dezi --dezi-config deziconfig.pl
>
> I get the following error:
>
> Error parsing deziconfig.pl: Undefined subroutine &Dezi::Config called at deziconfig.pl line 8.
> at /home/user1/perl5/perlbrew/perls/perl-5.24.0/bin/dezi line 58.


see edit below.


>
> 2. Earlier in my simpler setting where dezi client ran ok, when I tried running ui in my browser, e.g., http://localhost:5000/ui , I get error: 'Resource not found'. May be this path '/ui' is not set as default and I need to spell it out in the config file!

You need to add a:

use Dezi::UI;

to the top of your config.

>
> 3. One other question, what should I do in my dezi client script for executing a complex query that matches terms in different columns (something like a where clause in sql), e.g.: $query='field1:term1 AND field2:term2',
>
> Or to do complete field/column match: equivalent to using regex like, $field1=~/^term1$/
>


did you try the example you show above? I would expect this to work:


$query='field1:term1 AND field2:term2'

for regular expressions, you can't quite do those as full regex. You can use the
Wildcard though:

field1=term1*


>
> #deziconfig.pl
> ---------------
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> use Dezi::Config;
> use CHI;
>
> my $dezi_config = Dezi::Config({

should be:

my $dezi_config = Dezi::Config->new({


--
Peter Karman . he/him/his . 785.337.0405 . https://karpet.github.io/

raja raja

unread,
May 16, 2018, 3:51:44 PM5/16/18
to dezi-...@googlegroups.com
Thank you Peter. The UI works now..:). Will try this more and other stuffs along with complex queries.


> Sent: Tuesday, May 15, 2018 at 2:27 PM
> From: "Peter Karman" <pe...@peknet.com>
> To: dezi-...@googlegroups.com
> Subject: Re: [dezi-search] Dezi config
> --
> 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