# Searching is not working on relational data

**URL:** <https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822>\
**Category:** Help me!\
**Created:** [July 1, 2021, 9:53am UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822 "2021-07-01T09:53:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sourabht](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sourabht](https://community.forestadmin.com/u/sourabht)\
**Post date:** [July 1, 2021, 9:53am UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/1 "2021-07-01T09:53:42Z")

</div>

HI Team,

We are facing an issue with search from the provided search box on the relational fields.

below is the listing of data and apply filter but the data is not showing.

List of data.

 ![Screenshot_20210701_151703](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/1/1a3d034f84e11e2f0243777d5fcaad91f6ce2e8c.png)  
Applied filter with no response.  
 ![Screenshot_20210701_151802](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/5/58f554723c560f1a9dba91e7cf91ecd6d403dc38.png)

Below are the model definition:

```javascript
const schema = Mongoose.Schema({
    'talent': { type: Mongoose.Schema.Types.ObjectId, ref: 'users' },
    'follower': { type: Mongoose.Schema.Types.ObjectId, ref: 'users' },
    'created_at': Date,
    'updated_at': Date,
  }, {
    timestamps: false,
  });

```

Express: ~4.17.1  
forest-express-mongoose: ^7.0.0  
mongoose: 5.8.2

Thanks,  
Sourabh

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [July 1, 2021, 11:21am UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/2 "2021-07-01T11:21:30Z")

</div>

Hello @sourabht,

Thanks for your feedback.

Could you please activate the logs with `mongoose.set('debug', true);` and spot the request that is made when you apply this filter?

---

<div class="post-metadata">

**Author:** ![sourabht](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sourabht](https://community.forestadmin.com/u/sourabht)\
**Post date:** [July 1, 2021, 11:53am UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/3 "2021-07-01T11:53:03Z")

</div>

Hi @GuillaumeGautreau ,

I tried as you suggested please find below log.

```javascript
GET /forest/gigfollowers?timezone=Asia%2FCalcutta&fields%5Bfollower%5D=email&fields%5Bgig%5D=title&fields%5Bgigfollowers%5D=follower%2Cgig%2Cupdated_at%2Ccreated_at&page%5Bnumber%5D=1&page%5Bsize%5D=15&search=talent5%40mailinator.com&searchExtended=1&sort=-_id 304 - - 2.758 ms
Mongoose: gigfollowers.aggregate([{ '$match': { '$and': [ {}] } }, { '$group': { _id: null, count: { '$sum': 1 } } }], {})
GET /forest/gigfollowers/count?fields%5Bgigfollowers%5D=follower%2Cgig%2Cupdated_at%2Ccreated_at&fields%5Bfollower%5D=email&fields%5Bgig%5D=title&search=talent5%40mailinator.com&searchExtended=1&timezone=Asia%2FCalcutta 304 - - 16.408 ms

```

Thanks.

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [July 1, 2021, 12:13pm UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/4 "2021-07-01T12:13:16Z")

</div>

It looks like the URL in your log does not match the search you’re showing in your screen capture. Are you sure you did the same search in both cases?

For your information, I tried to replicate your issue on my side, but for now I could not. I created a relationship just as you did, but the filter is working as expected.

---

<div class="post-metadata">

**Author:** ![sourabht](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sourabht](https://community.forestadmin.com/u/sourabht)\
**Post date:** [July 1, 2021, 12:19pm UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/5 "2021-07-01T12:19:13Z")

</div>

Yes, apply a filter is working.

but when I enter something on the below box then the search is not working.

 ![Screenshot_20210701_174830](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/5/5f3c4ad723521194401a5c5d93d612d945831897.png)

Thanks.

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [July 1, 2021, 12:27pm UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/6 "2021-07-01T12:27:11Z")

</div>

You are right, the search feature does not search into related data. This is done because of performance reasons, in some cases, searching in all related collections can be very time consuming and we cannot implement this in all cases.

If it’s important for you, it might be possible to override the route that is used to search for values.

I’m adding this suggestion to our product board, that lists all improvement suggestions.

---

<div class="post-metadata">

**Author:** ![sourabht](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sourabht](https://community.forestadmin.com/u/sourabht)\
**Post date:** [July 1, 2021, 1:29pm UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/7 "2021-07-01T13:29:58Z")

</div>

Thanks for detailed information @GuillaumeGautreau .

---

<div class="post-metadata">

**Author:** ![louis](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louis/32/4_2.png) [@louis](https://community.forestadmin.com/u/louis)\
**Post date:** [July 2, 2021, 7:02am UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/8 "2021-07-02T07:02:48Z")

</div>

@sourabht can you try to click on “Try an extended search” at the bottom after doing the search?

Let me know if that helps

---

<div class="post-metadata">

**Author:** ![sourabht](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sourabht](https://community.forestadmin.com/u/sourabht)\
**Post date:** [July 2, 2021, 7:12am UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/9 "2021-07-02T07:12:40Z")

</div>

Hi @louis ,

I tried with “Try an extended search” getting the below result.

 ![Screenshot_20210702_123844](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/d/d52b74b445b84ef344678b3587b0b44be2a57493.png)

Thanks,  
Sourabh

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [July 2, 2021, 7:24am UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/10 "2021-07-02T07:24:01Z")

</div>

I’m having the same result on my test project. I’m investigating this problem. I’ll get back to you when I have more info.

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [July 2, 2021, 8:06am UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/11 "2021-07-02T08:06:27Z")

</div>

It seems that the extended search works only on nested fields on `forest-express-mongoose`, but not on relationships.

I’m creating an issue on our side to see if we can add it.

---

<div class="post-metadata">

**Author:** ![sourabht](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sourabht](https://community.forestadmin.com/u/sourabht)\
**Post date:** [July 2, 2021, 8:16am UTC](https://community.forestadmin.com/t/searching-is-not-working-on-relational-data/2822/12 "2021-07-02T08:16:13Z")

</div>

Thank you @GuillaumeGautreau .
