Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Andrea Landonio

    (@lando1982)

    Hi,
    sorry I’m late, I was on holidays ??
    It’s my fault because I set the Italian as default but it’s a better solution to use WordPress language.. I’m sorry…
    I’m working on a big plugin extension now but I keep your problem in my todo list and I fix it as soon as possible..
    For now, you can only alter fields in the AWS console.. ??

    Plugin Contributor sburdett

    (@sburdett)

    No worries just thought I would ask. I’m enjoying the challenge of integrating the plugin into our site which uses a custom search plugin. Great plugin, thanks!

    Plugin Author Andrea Landonio

    (@lando1982)

    Thanks to you! Your issue is a good point! I’ll fix it ??

    Plugin Contributor sburdett

    (@sburdett)

    You said you use this for more advanced searches at your company. Do you manually convert the WP-Queries to Lucene or is there a library for this? I have the system working for simple queries like:

    Array (
    [post_type] => custom
    [meta_query] => Array (
    [1] => Array (
    [key] => FOO
    [value] => BAR
    )
    )

    by converting the array to variables $key_type = ‘foo’; and $key = ‘bar’;

    However, I am having issues for more complex searches like:

    Array (
    [post_type] => custom
    [meta_query] => Array (
    [0] => Array (
    [key] => custom_key
    [compare] => EXISTS
    )
    [1] => Array (
    [key] => FOO
    [value] => BAR
    )
    [2] => Array (
    [key] => number
    [value] => Array (
    [0] => 4
    [1] => 6
    )
    [type] => numeric
    [compare] => BETWEEN
    )
    [3] => Array (
    [key] => number
    [compare] => NOT IN
    [value] => Array (
    [0] => [1] => None [2] => none
    )
    )
    [4] => Array (
    [key] => custom_key
    [value] => 2
    )

    [paged] => 1
    [posts_per_page] => 10
    [order] => DESC
    [post_status] => publish
    [orderby] => date
    )

    I guess I can write a custom decode but I thought maybe you had a better more inclusive option.

    • This reply was modified 6 years, 3 months ago by sburdett.
    Plugin Contributor sburdett

    (@sburdett)

    Also just out of curiosity, how come you convert all the index field name dashes to underscores?

    Plugin Author Andrea Landonio

    (@lando1982)

    Hello,

    the conversion is due to an Amazon CloudSearch valid pattern rule ??

    for the complex queries, in our “complex” sites we’ve integrated in our code calls to my plugin method, I’ll try to example better with an example:

    // Prepare CloudSearch search keyword
    if (!empty($topics)) {
    // Loop keys
    $keyword = ‘(or’;
    foreach ($topics as $topic) {
    $keyword .= ‘ ct_topic:\” . $topic . ‘\”;
    }
    $keyword .= ‘)’;
    }

    // Prepare CloudSearch filter query (filtering site id, post types (post, legacy), specified origins, author and excluded posts)
    $filter_query .= ‘(and (or (and site_id:’ . ACS::get_instance()->get_site_id() . ‘ blog_id:’ . ACS::get_instance()->get_blog_id() . ‘ (or post_type:\’post\’)))’;
    if ($post_origin != \CN_Model\Application\App::get_instance()->get_config(‘ORIGIN_ALL’)) {
    // Filter specified origin
    $filter_query .= ‘ cf_cms_origin:\” . $post_origin . ‘\”;
    }
    if ($author_id != 0) {
    // Filter author
    $filter_query .= ‘ post_author:’ . $author_id;
    }
    if ($filter_related) {
    // Filter related flag
    $filter_query .= ‘ (not cf_cmb_post_show_in_related:\’no\’)’;
    }
    if (!empty($posts_excluded)) {
    // Filter excluded posts
    foreach ($posts_excluded as $post_excluded) {
    $filter_query .= ‘ (not id:’ . $post_excluded . ‘)’;
    }
    }
    if (!empty($filters)) {
    // Custom filters
    foreach ($filters as $filter_key => $filter_value) {
    $filter_query .= ‘ ‘ . $filter_key . ‘:\” . $filter_value . ‘\”;
    }
    }
    $filter_query .= ‘)’;

    try {
    // Search full data
    $acs_result = acs_index_documents_search($keyword, ACS::SEARCH_FIELD_DEFAULT, $start, $posts_per_page, ‘structured’, $filter_query, true, ACS::TYPE_FIELD_DEFAULT, $order_by, $order, false);
    $result_search = $acs_result->get_data();
    }
    catch (Exception $e) {
    $result_search = array();
    }

    // Documents founded
    if (!empty($result_search) && count($result_search[‘items’]) > 0) {
    for ($i = 0; $i < count($result_search[‘items’]); $i++) {
    // Get document
    $item = $result_search[‘items’][$i];

    }
    }

    In other words, we prepare keyword and filter_query (you can use the Amazon CloudSearch console to test it), then execute a “acs_index_documents_search” to query the index and in the end loop towards the results.
    This is the server side way.. alternatively for a client side solution you can do the use creating an API an contacting a JSON results via a JS framework for example..

    Let me know if you have any question..
    Bye

    Plugin Contributor sburdett

    (@sburdett)

    SO I got that working, basically the same as you show above. For some reason, however, one of the fields, vital to my search, would not populate for any of my documents. SO I deleted the entire domain on Cloud Search and started over. Now for some reason, the documents won’t sync at all. It builds the index, says syncing, but no searchable documents are created. I don’t see any errors to debug. Any ideas?

    Plugin Author Andrea Landonio

    (@lando1982)

    Some questions:
    – the field exists in the CloudSearch index? If yes, is it “checked” in the settings page?
    – if you look the number of documents on the index, it says “0”?
    – can you tell the name of the field that doesn’t work?

    Try to tell me more info please… ??

    Plugin Contributor sburdett

    (@sburdett)

    It seems to have to do with the number of documents. When I only turn on post and pages it loads up 28 documents. But when I turn on my custom post type, that has around 950 documents, it does not load any. Says sync in progress to 900 then goes away and does not sync any documents.

    Here are a couple screen shots:

    https://snag.gy/yFZc4R.jpg

    https://snag.gy/SrJyvp.jpg

    Plugin Contributor sburdett

    (@sburdett)

    Figured it out. The upload was throwing an error to the admin error log I just missed it somehow. This is a test site so the log had a bunch of stuff in it and I just didn’t see the error at first. Just a feature request, it would be nice if there was some more prominent error thrown. If a user didn’t know to check the server error logs they would never see this and just be stuck scratching there head.

    The error was caused by a field that was not a string or array:

    [29-Aug-2018 20:05:44 UTC] Error uploading documents: { [“The value for the “cf_location_map” field must be a string or array (near operation with index 1; document_id 1_1_3340)”] }

    In Case you were curious.

    Thanks again, great plugin.

    • This reply was modified 6 years, 3 months ago by sburdett.
    Plugin Author Andrea Landonio

    (@lando1982)

    Thanks a lot! I confirm to you that the number of documents isn’t a problem ?? I have site with over then 50K posts synced..

    Plugin Author Andrea Landonio

    (@lando1982)

    Hi, new release with schema language option ??

    You can choose the Analysis schema language for the CloudSearch index in three ways:
    – Use a constant: define in your “wp-config.php” the constant “WP_ACS_SCHEMA_LANGUAGE” with the desired language
    – Use the WordPress locale: if no constant is defined the plugin takes automatically the same language of your WordPress installation
    – Use defaults: as last option, the plugin use a “Multi-language” setting as default

    Thanks for your suggestion..

    Plugin Contributor sburdett

    (@sburdett)

    Awesome, thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Analysis Scheme’ is closed to new replies.