Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add getter to access OpenSearchServer\Document\Document fields #49

Closed
a4i opened this issue Feb 1, 2015 · 2 comments
Closed

add getter to access OpenSearchServer\Document\Document fields #49

a4i opened this issue Feb 1, 2015 · 2 comments

Comments

@a4i
Copy link

a4i commented Feb 1, 2015

It would be great to have fields accessor in OpenSearchServer\Document\Document.

We need this to inspect document content while processing exceptions (and to save document unique field for future processing, for example)
No way to access the "fields" protected property for now.

Regards

@a4i
Copy link
Author

a4i commented Feb 1, 2015

Something like this :

    public function getField($fieldName) {
        if(empty($fieldName)) {
            throw new \InvalidArgumentException('Please provide a fieldname');
        }
        $values = array();
        array_map( function ($f) use (&$values, $fieldName) {
            if ( $f['name']===$fieldName) {
                array_push($values, $f["value"]);
            }
        }, $this->fields);
        return $values;
    }

AlexandreToyer added a commit that referenced this issue Feb 2, 2015
@AlexandreToyer
Copy link
Member

Hi,

Thank you, I added some code in class Document (I used a foreach instead of array_map).

Alexandre

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants