AWS Cloudsearch - I can’t find words that end with the string

Asked

Viewed 41 times

0

I’m using the CloudSearch of Amazon. But I have a problem searching the words that end with a certain term, I can’t perform this type of search, it returns me only the records that start with the term, for example: I have registered TESTEA and ATESTE.

Digito: TESTE* or TESTE or *TESTE

the result will only refer to the TESTEA

I have read the documentation and some topics and did not succeed.

Has anyone been through this problem and has any suggestions?

1 answer

0


After a few attempts of examples and unsuccessfully. I solved as follows:

I created a text-array field and stored part of the string backwards and worked on it.

example: my string is "abcde" and I search bcde. this would not work but in my text-field will be the following strings: e,de,Cde,bcde,abcde. So you will find "abcde" as you will find the term in the text-array field.

Putz, but what if I search "Bcd" this terminus is not in the text-array field. Beauty but the string "bcde" starts with "Bcd" so you will find.

my php file to insert got this way:

$term = "abcde";

$arrStr = str_split($term);
$arrTerms = [];
$aux = 1;
foreach($arrStr as $str){
    $arrTerms[] = substr($term,($aux * -1));
    $aux++;
}

$data = [
    'type'   => 'add',
    'id'     => [your_id],
    'fields' => [
        'id' => [your_id],
        'field-text' => $term
        'field-text-array' => $arrTerms

    ],
];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.