# Jupyter + Siren

**URL:** <https://community.siren.io/t/jupyter-siren/396>\
**Category:** Siren Platform/Investigate Tech Support Community\
**Created:** [July 12, 2021, 3:10pm UTC](https://community.siren.io/t/jupyter-siren/396 "2021-07-12T15:10:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Kafonek](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.siren.io/matt_kafonek/32/205_2.png) [@Matt\_Kafonek](https://community.siren.io/u/Matt_Kafonek)\
**Post date:** [July 12, 2021, 3:10pm UTC](https://community.siren.io/t/jupyter-siren/396/1 "2021-07-12T15:10:09Z")

</div>

_(edit: if a moderator wants to move this post to the Siren Federate forum it might make more sense than here in the Investigate/UI section)_

I have been exploring programmatic interaction from Python/Jupyter to Siren endpoints, and have seen some unexpected behavior with querying and projecting fields in the `/siren/<index>/_search` endpoints. They may be bugs, or I may be misunderstanding the documentation. I put together a small repo that will start up Siren’s demo container and a single-user Jupyter environment via `docker-compose` at [GitHub - kafonek/siren: Demo and bug reporting for Jupyter Notebook interaction to Siren-Elasticsearch](https://github.com/kafonek/siren) in case you want to reproduce the queries.

I’ve shown the raw RESTful queries for the bugs (?) in the [`/notebooks/bugs`](https://github.com/kafonek/siren/tree/main/notebooks/bugs) directory. The first issue is that `project` fields are not coming back in my result set. ~~The second issue is DSL parse errors while trying to include query terms for one index while also joining to another index.~~ _([Filtering by Both Indices](https://community.siren.io/t/filtering-by-both-indices/58) explains how to do the boolean must query)_

Any advice on those bug Notebooks is appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![Stephane\_Campinas](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.siren.io/stephane_campinas/32/22_2.png) [@Stephane\_Campinas](https://community.siren.io/u/Stephane_Campinas)\
**Post date:** [July 20, 2021, 12:06pm UTC](https://community.siren.io/t/jupyter-siren/396/2 "2021-07-20T12:06:31Z")

</div>

Hello Matt,

You must use a [`script_fields`](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-fields.html#script-fields) in order to see the project fields in the response. See example in [Query domain-specific language (DSL) :: SIREN DOCS](https://docs.siren.io/siren-federate-user-guide/24/siren-federate/query-dsl.html#siren-federate-query-dsl-project) where you see the following:

```json
{
    ...,
    "script_fields" : {
      "employees_age" : {
        "script" : "doc.employee_age"                                    
      }
    }
}

```

In general, you just need to refer in the script the field you want to see, e.g., for your demo, it would be:

```auto
{
    ...,
    "script_fields" : {
      "article" : {
        "script" : "doc.article_source"                                    
      }
    }
}

```

Cheers,

---

<div class="post-metadata">

**Author:** ![Manu\_Agarwal](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.siren.io/manu_agarwal/32/120_2.png) [@Manu\_Agarwal](https://community.siren.io/u/Manu_Agarwal)\
**Post date:** [July 20, 2021, 1:14pm UTC](https://community.siren.io/t/jupyter-siren/396/3 "2021-07-20T13:14:19Z")

</div>

Hi Matt,

As Stephane mentioned here is the query for your use case to expect to see `{'fields': {'article_source': [<value>]}}` in the results:

```auto
GET /siren/company/_search
{
   "query": {
    "join": {
      "indices": ["article"],
      "on": ["id", "companies"],
      "request": {
        "project" : [
            { "field" : { "name" : "article.source", "alias" : "article_source" } }  
        ],
         "query": {
          "bool": {
            "filter": [{
              "term": {
                  "article.source": "New York Times"
              }
            }
            ]
          }
        }
          }
        }
},
"script_fields" : {
      "article_source" : {
        "script" : "doc.article_source" 
      }
    }
    }

```

Regards  
Manu
