-
Notifications
You must be signed in to change notification settings - Fork 89
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
Aggregate is casting numbers? #158
Comments
That happens because you are using the method |
Interesting, That makes sense, I'm curious then why would it not be casting the single model algolia import to a number given the |
Can you re-phrase your question? |
Well, As shown above, we have the Next we have an Aggregate defined. We're sending both these things up to Algolia, yet only the aggregate has the casting happening. |
This is the /**
* Get the searchable array of the searchable.
*
* @return array
*/
public function toSearchableArray(): array
{
if ($this->model === null) {
throw new ModelNotDefinedInAggregatorException();
}
return method_exists($this->model, 'toSearchableArray') ? $this->model->toSearchableArray() :
$this->model->toArray();
} So yes, it should affect both the single-model-type index, and the aggregate index. |
@nunomaduro So I figured I'd disable the
But found something strange, In the aggregator the It's because this check is failing Specifically because the Easy fix, just adding the following to my own Aggregator.
Could explain why I'm getting different transforms depending on whether it's a different model, regardless, the |
@hailwood Not sure if I understood. But if you are sure that there is a big here, do you mind of submit a PR with tests? |
I have a model where we have a field, "line_id" the db type is string..
This looks like a number but it's not as we have e.g. "831", but we also have "062", the leading zero is important.
Our models
toSearchableArray
looks like this (Model is DDI):scout:import against the model works fine and in the index we see
![image](https://user-images.githubusercontent.com/709773/53528546-c16aca80-3b4e-11e9-8236-7536472b9971.png)
We also have an aggregate defined which looks like this
And that DDI that's imported looks like this in the search index
![image](https://user-images.githubusercontent.com/709773/53528678-3211e700-3b4f-11e9-9b3f-c6d21b59612e.png)
So why would the aggregate be casting line_id to a number hence dropping the leading zero and how can I fix it?
The text was updated successfully, but these errors were encountered: