MAM works for one-to-one chats archive but not group chats archive

Hi, I am trying to implement the MAM on Android Smack client. I have installed Monitor Service plugin on Openfire 4.2.3 and enabled the archive for one-to-one chats and group chats.

For one-to-one chats, the server forwarded the archived messages successfully based on the client query:
D/SMACK: SENT (0): <iq id='fBx7o-149' type='set'><query xmlns='urn:xmpp:mam:1' queryid='c2d0679b-c1a8-4ac3-8aed-485c339d7355'><x xmlns='jabber:x:data' type='submit'><field var='FORM_TYPE' type='hidden'><value>urn:xmpp:mam:1</value></field><field var='with'><value>281001@imserver</value></field></x><set xmlns='http://jabber.org/protocol/rsm'><before/><max>10</max></set></query></iq>

D/SMACK: RECV (0): <message to="241099@imserver/Smack"><result xmlns="urn:xmpp:mam:1" queryid="c2d0679b-c1a8-4ac3-8aed-485c339d7355" id="15"><forwarded xmlns="urn:xmpp:forward:0"><delay xmlns="urn:xmpp:delay" stamp="2018-10-31T06:24:08.419Z"/><message xmlns="jabber:client" to="241099@imserver" id="154096705032733122" type="chat" from="281001@imserver/Smack"><thread>a705cc85-138b-4c68-9692-d53dcc685b71</thread><body>jjk</body><request xmlns="urn:xmpp:receipts"></request></message></forwarded></result></message>

D/SMACK: RECV (0): <r xmlns='urn:xmpp:sm:3' /><message to="241099@imserver/Smack"><result xmlns="urn:xmpp:mam:1" queryid="c2d0679b-c1a8-4ac3-8aed-485c339d7355" id="16"><forwarded xmlns="urn:xmpp:forward:0"><delay xmlns="urn:xmpp:delay" stamp="2018-10-31T06:24:19.662Z"/><message xmlns="jabber:client" to="241099@imserver" id="154096706155506039" type="chat" from="281001@imserver/Smack"><thread>a705cc85-138b-4c68-9692-d53dcc685b71</thread><body>nnn</body><request xmlns="urn:xmpp:receipts"></request></message></forwarded></result></message><message to="241099@imserver/Smack"><result xmlns="urn:xmpp:mam:1" queryid="c2d0679b-c1a8-4ac3-8aed-485c339d7355" id="18"><forwarded xmlns="urn:xmpp:forward:0"><delay xmlns="urn:xmpp:delay" stamp="2018-10-31T06:25:51.498Z"/><message xmlns="jabber:client" to="281001@imserver" id="154096716902311056" type="chat" from="241099@imserver/Smack"><thread>46f79825-dc65-4e58-ab12-15b8d70a97ff</thread><body>ghj</body><request xmlns="urn:xmpp:receipts"></request></message></forwarded></result></message><iq type="result" id="fBx7o-149" to="241099@imserver/Smack"><fin xmlns="urn:xmpp:mam:1" queryid="c2d0679b-c1a8-4ac3-8aed-485c339d7355"><set xmlns="http://jabber.org/protocol/rsm"><first index="1">3</first><last>18</last><count>11</count></set></fin></iq>

However, no archived message is forwarded by server when client queries the group chats archive, the server does return the result IQ to signal the end:

D/SMACK: SENT (0): <iq id='KiTps-131' type='set'><query xmlns='urn:xmpp:mam:1' queryid='d49bfa46-3995-4fd1-9f9f-07f92fac0934'><x xmlns='jabber:x:data' type='submit'><field var='FORM_TYPE' type='hidden'><value>urn:xmpp:mam:1</value></field><field var='with'><value>pki@conference.imserver</value></field></x><set xmlns='http://jabber.org/protocol/rsm'><before/><max>10</max></set></query></iq>

D/SMACK: RECV (0): <iq type="result" id="KiTps-131" to="241099@imserver/Smack"><fin xmlns="urn:xmpp:mam:1" queryid="d49bfa46-3995-4fd1-9f9f-07f92fac0934"><set xmlns="http://jabber.org/protocol/rsm"><first index="4">6</first><last>17</last><count>14</count></set></fin></iq>

Appreciate it if anyone could help to identify why the group chats archive is not working. Thanks!

It seems to work fine now for group chats archive when I started a new group chat or Rebuild Index. Probably the old group chats weren’t indexed or archived properly.