They both add documents to the same index "rq3" and perform a "group_by" and "count" action over an attribute called "OwnerUserId". However, the first transformation only performs this actions over the documents with "PostTypeId" equals to 1 and the second, only over "PostTypeId" equals to 2.
The problem is that, when I review the "rq3" index, there are not "OwnerUserId" with "count_questions" and with "count_answers" (and should be). It seems like the second transformation is updating the repeated "OwnerUserId" and removing those equals to the first transformation.
How can I count "PostTypeId" equals to 1 and "PostTypeId" equals to 2 and relating these two values with their "OwnerUserId" using transformations?
2 transforms should not write into the same index. As it happened for you: they might overwrite documents from each other. In addition to that, transform always writes new documents, it can not update old ones. You should use 1 transform instead.
To implement your usecase you need to use a scripted metric aggregation. A similar usecase to yours is available on the transform examples page. Have a look how responses.counts works. I think you should be able to do something similar for count_answer and count_question.
We are working on improving the transform API, adding support for filter aggregations - which I think would be the easiest solution for your usecase - is on our backlog.
I tried my best to apply that example to my use case, but I could not make the transform work. It is because I want to count not only each type of post (answer or question) but each type of post per user (number of answers of user 1, number of questions of user 1, number of answers of user 2, number of questions of user 2 ... Can you show me an example of how my use case could be solved? @Hendrik_Muhs
Did you find a solution? Due to holidays I had no time to look into it. The solution I had in mind was to create 1 counter for answers, 1 for questions and use a if on PostTypeId to increment them. The example for response codes is similar to that.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.